I just started Java
course in college, I'm trying to understand the concept of OOPs
so I wrote this program:
package Lamp;
import java.util.*;
public class Lamp {
public Scanner input= new Scanner(System.in);
boolean state;
String color;
public Lamp() {
state = false;
color = "Blue";
}
public boolean toggleState() {
if (state == false) {
state = true;
}
if (state == true) {
state = false;
}
System.out.println("State is now: " +state);
return state;
}
public String chooseColor(){
System.out.println("Please choose a new color");
color= input.nextLine();
System.out.println("Color is now: " +color);
return color;
}
void main(){
Lamp L1= new Lamp();
System.out.println("State is now: " +state);
System.out.println("Color is now: " +color);
L1.toggleState();
L1.chooseColor();
System.out.println("State is now: " +state);
System.out.println("Color is now: " +color);
}
}
The problem is that every time I try to run the program, NetBeans says that it can't find the main class which is Lamp.Lamp
I'm using the concept of packagename.classname
, but it keeps putting the same thing.
Thanks in advance!