Skip to content
← Back to Community
Creating and running a public class
Profile icon
golazo08

Why does my public class SecondClass not run? Do I always have to use public Main? What if I want to create and run a public class?

Voters
Profile icon
AliEl-Tawil
Profile icon
wgibson
Profile icon
Frastea
Profile icon
AdegbenroD
Profile icon
sm28748
Profile icon
golazo08
Comments
hotnewtop
Profile icon
vedprad1

You can only run the Main class. If you want to run another class, you have to use Objects.

Profile icon
Geocube101

I can't seem to see or find your code, but the Main.java file must contain a Main class and a main function for it to run. You can create other classes and run them from main though.