0

Can anyone help me fix this im new to class i want 2 classes "helloandbye" and "names" but its not working. Thanks

public class HelloAndBye { static String x; static String y; public class Names { static string a; static string b; public static void main(String[] args) { String x = "Hello "; String y = "Bye "; System.out.println(x); a= "Harry"; b= "Tony"; System.out.println(a); } } }

11th Jul 2017, 9:14 PM
D_Stark
D_Stark - avatar
6 Answers
+ 2
If you didn't want nested then you need to end the first class's block with a }, before the class Names. Example/ class a { } class b { }
11th Jul 2017, 10:22 PM
Rrestoring faith
Rrestoring faith - avatar
0
Just capitalize the type definition of a and b --> static String a; As you did with x and y.
11th Jul 2017, 9:24 PM
Si Ogn
0
i did that but its saying that its an illegal static inside inner class :/
11th Jul 2017, 9:40 PM
D_Stark
D_Stark - avatar
0
You want this to be nested class or normal class?
11th Jul 2017, 9:48 PM
Tay Cheng Yik
0
normal please :)
11th Jul 2017, 10:11 PM
D_Stark
D_Stark - avatar
0
@Rrestoringfaith that worked great thanks!, may i ask what nested means? thanks
11th Jul 2017, 10:37 PM
D_Stark
D_Stark - avatar