make a class in java code example
Example 1: using class in java
public class HelloWorld {
public static void main(String[] args) {
class User{
int score;
}
User dave = new User();
dave.score = 20;
System.out.println(dave.score);
}
}
Example 2: java class
public class TestClass {
private int id = 111;
public TestClass(){
super();
}
public void test(){
}
}
Example 3: using class in java
public class HelloWorld {
public static void main(String[] args) {
class User{
int score;
public boolean hasWon(){
if(score >= 100){
return true;
} else {
return false;
}
}
}
User dave = new User();
dave.score = 20;
System.out.println(dave.hasWon());
}
}