java - Why I cannot declare obj class as public? -
i'm trying declare obj class public says class obj public should declared in file named obj.java
.
public class obj { string name; public void show() { system.out.println (name ); } } public class objects { public static void main (string args[]){ obj object 1=new obj (); object1.name="sam"; object1.show(); } }
the answer in question. file not called obj.java. have classes in separate files: obj.java , objects.java.
by way, java convention start class names uppercase, e.g. obj instead of obj. also, want pick more descriptive names.
Comments
Post a Comment