I've written the below code in a text file and saved it as Exercise1.java:
import java.util.*;
public class Exercise1
{
public static void main(String[] args)
{
char myChar;
int myInt;
System.out.println(myChar);
System.out.println(myInt);
}
}
then in cmd I write
javac D:\Projects\Exercise1.java
I get 2 errors both saying the declared variables might not be initialized. But if I initialize the variables the above code generates the "Exercise1.class" file. And then when I write
java D:\Projects\Exercise1
I get java.lang.ClassNotFoundException. Now what I wonder are:
- Aren't primitive types initialized to default values in Java (I thought and read they did).
- Why can't I run my program and get the Exception as there do not not seem to be any mistakes?