java - Instantiating objects in a class from a different class with netBeans -


this question has answer here:

i can't seem instantiate object class i've written main method. don't know if problem code or netbeans. here's program comments solely question:

package app; import java.util.scanner; public class setupsite { public static void main(string[] args) {     final int founded_year = 1977;     int currentyear;     int age;     statementofphilosophy();     scanner reader = new scanner(system.in);     //the next line line unrecognized     eventsite onesite = new eventsite();     int sitenum;     system.out.print("enter event site number: ");     sitenum = reader.nextint();     onesite.setsitenumber(sitenum);     system.out.print("enter current year of company: ");     currentyear = reader.nextint();     system.out.println("the age of company "+ calculateage(founded_year,        currentyear) + " years");  }  public static void statementofphilosophy() { system.out.println("event handlers inc"); } public static int calculateage(final int original_year, int currentdate) {     int years = currentdate - original_year;     return years;  }  public class eventsite { private int sitenumber;  public void onesite() {  } public int getsitenumber() { return sitenumber; }  public void setsitenumber(int n) {     sitenumber = n; }  } } 

eventsite public inner class of setupsite, , messing up. eventsite class code out of setupsite class , instead put in own file belongs. java file cannot have more 1 top-level public class.

you make private inner class, , make static internal class, no reason doing so, or make private , create on top of setupsite instance, ugly , unnecessary kludge.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -