Im new to java so i imagine this is a very obvious question but for the life of me i dont know why this dosent work, i am extremely cluless
public class start {
public static void main(String[] args){
Shop shop = new Shop();
shop.tellMe();
}
static class Shop{
Item wares;
void tellMe(){
this.wares.itemOut();
}
}
public class Item{
int price = 0;
String name = "Sunglasses";
void itemOut(){
System.out.println(price + " " + name);
}
}
}
I feel like this should work, but when i run it i get
Exception in thread "main" java.lang.NullPointerException
at start$Shop.tellMe(start.java:14)
at start.main(start.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)m