+ 1

Error

When i build this data object model below in Java programming i ran into a bunch of errors! what's wrong? You can try this code on the sololearn integreted code editor and see what the hell occurs The Code public class Book { // FIELDS public String id; public String name; public String author_id; public class Author { // FIELDS public String id; public String name; public String birthDay; // RESOLVERS public static String getAuthorId(){ return id; } public static String getName(){ return name; } public static String birthDay(){ return birthDay; } } // RESOLVERS public static String getBookId(){ return id; } public static String getBookName(){ return book; } public static String getAuthor(){ Author a = new Author(); } }

10th May 2020, 3:21 PM
Mouad Taoussi
Mouad Taoussi - avatar
7 odpowiedzi
+ 2
where is the code??
10th May 2020, 4:19 PM
Ahmed Mostafa
Ahmed Mostafa - avatar
+ 2
Static members belong to the whole class and not to a specific instance of a class.
10th May 2020, 5:26 PM
Avinesh
Avinesh - avatar
+ 2
Got it. Thanks!
10th May 2020, 5:32 PM
Mouad Taoussi
Mouad Taoussi - avatar
+ 1
Mouad Taoussi The code? That didn't help at all. Please share with us the actual code that you wrote and ran into a specific problem.
10th May 2020, 4:28 PM
Avinesh
Avinesh - avatar
+ 1
sorry i went wrong! here is the code above
10th May 2020, 4:41 PM
Mouad Taoussi
Mouad Taoussi - avatar
+ 1
you must remove *static* from methods https://code.sololearn.com/cMmCtI8Mlufp/?ref=app
10th May 2020, 4:58 PM
Ahmed Mostafa
Ahmed Mostafa - avatar
+ 1
it works! but why we have to delete static in this instance?
10th May 2020, 5:21 PM
Mouad Taoussi
Mouad Taoussi - avatar