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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -