Answers for "declaring class in java"

1

using class in java

public class HelloWorld {
  public static void main(String[] args) {
   
   
   class Number{
   
   	int number;
   
   	public boolean isPos(){
   		if(number > 0){
   			return true;
   		} else {
   			return false;
   		}
   		
   	}
   }
   
   Number myNumber = new Number();
   
   myNumber.number = 7;
   
   if(myNumber.isPos()){
   	System.out.println(myNumber.number + " is positive!!!");
   } else {
   	System.out.println(myNumber.number + " is not positive!!!");
   }
   
  }
}
Posted by: Guest on March-10-2020
0

how to make a class in java

public class Main {
 public static void main (String[] args) {
	System.out.println("Hello World");
 } 
}
Posted by: Guest on November-19-2019

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language