Whst did I do wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4 Answers
+ 3
/*You have written class name two times in the top of the code Try this one */ public class Person{ int age; String color; String series; String game; void hinkeln(){ System.out.println("hinkel honkel"); } public static void main(String[] args) { Person max = new Person(); max.color = "schwarz"; max.game = "cool game"; max.series = "cool series"; max.hinkeln(); } }
24th Nov 2021, 1:00 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Max Yes. In this form: public class Person{ int age; String color; String series; String game; void hinkeln(){ System.out.println("hinkel honkel"); } } public class Program{ public static void main(String[] args) { Person max = new Person(); max.color = "schwarz"; max.game = "cool game"; max.series = "cool series"; max.hinkeln(); } } Person is a class and Program is your main class.
24th Nov 2021, 4:06 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Denise Roßberg didn't think of that. This is smart, thanks 👌🤝
25th Nov 2021, 6:23 AM
Max
Max - avatar
0
Thanks now i get it somehow. i have one question though: Do you need to close "public class Person" (!)at the end(!) to make that class acessable for the main class?
24th Nov 2021, 1:54 PM
Max
Max - avatar