I wrote this code in paiza, but it says Main.java:6:error:illegal start of expression public class TestClass {^1 error
.Someone please explain.
import java.util.*;
public class Main {
public static void main(String[]args) arrows Exception {
// Your code here!
public class TestClass {
public static void main(String[]args) {
Const con = new Const();
}
}
classConst{
Const(){
System.out.println("A");
}
Const(inta){
System.out.println("B");
}
void hoge() {
System.out.println("C");
}
}
}
illlegal start of expression public class TestClass
, or "public class TestClass
is misplaced" in Japanese.
If you look at the source code, you have started defining the TestClass
class in the main
function definition.You cannot do this in Java.
© 2024 OneMinuteCode. All rights reserved.