fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class IfElseDemo {
  9. public static void main(String[] args) {
  10.  
  11. int testscore = 76;
  12. char grade;
  13. String des;
  14.  
  15. if (testscore >= 90) {
  16. grade = 'A';
  17. des = "Manager";
  18. } else if (testscore >= 80) {
  19. grade = 'B';
  20. des = "Employee";
  21. } else if (testscore >= 70) {
  22. grade = 'C';
  23. des = "Staff";
  24. }
  25. System.out.println("Grade = " + grade);
  26. //System.out.println("Grade = " + des);
  27. }
  28. }
Compilation error #stdin compilation error #stdout 0.06s 3359744KB
stdin
Standard input is empty
compilation info
Main.java:25: error: variable grade might not have been initialized
        System.out.println("Grade = " + grade);
                                        ^
1 error
stdout
Standard output is empty