Main.java:6: error: illegal start of expression public class TestClass {^1 error.

Asked 1 years ago, Updated 1 years ago, 351 views

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");
        }
    }
    }

java

2022-10-12 01:00

1 Answers

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.


2022-10-12 01:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.