Answers for "java initialize variable without value"

0

java initialize variable without value

// you must initialize local variables before you use them
public class Variables{
  public static void main(String[] args){
  	// variable declaration
	int i; 
  	// this will result in an error 
  	// because variable 'i' is not initalizied yet
  	System.out.println("i = " + i);
  	// variable initalization
	i = 0;
  	// output: i = 0
	return System.out.println("i = " + i);
  }
}
Posted by: Guest on October-26-2021

Code answers related to "java initialize variable without value"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language