ok so every time i go to create an object, i get a syntax error that says " x can not be resolved to a type. for example, my line says
Sniper s1;
"Sniper s1 = new Sniper(); "
i might be doing something wrong. can anyone explain how to make objects?
// Instantiate the object at declaration
Sniper s1 = new Sniper();
or
// Declare object now and instantiate the object later
Sniper s2;
s2 = new Sniper();
Sniper.java:
package my.sniper.package;
public class Sniper {
...
}
main.java:
package my.main;
import my.sniper.package.Sniper;
public class Main{
public static void main(String[] args){
Sniper s1 = new Sniper();
Sniper s2 = null;
s2 = new Sniper();
}
}
Users browsing this forum: No registered users and 0 guests