Local Variable

  1. class Lvar
  2. {
  3. int a;
  4. void access()
  5. {
  6. String b;
  7. System.out.println(a);
  8. System.out.println(b);
  9. }
  10. public static void main (String ...x)
  11. {
  12. Lvar x1 = new Lvar();
  13. x1.access();
  14. }
  15. }
  16. Output:
  17. Lvar.java:8: error: variable b might not have been initialized System.out.println(b); ^ 1 error
  1. class Lvar
  2. {
  3. int a;
  4. void access()
  5. {
  6. String b="NULL";
  7. System.out.println(a);
  8. System.out.println(b);
  9. }
  10. public static void main (String ...x)
  11. {
  12. Lvar x1 = new Lvar()
  13. x1.access();
  14. }
  15. }
  16. Output:
  17. 0
  18. NULL
  1. class Lvar
  2. {
  3. int a;
  4. void access()
  5. {
  6. String b="NULL";
  7. System.out.println(a);
  8. System.out.println(b);
  9. }
  10. public static void main (String ...x)
  11. {
  12. Lvar x1 = new Lvar();
  13. x1.access();
  14. }
  15. }
  16. Output:

-Webpage Under Development-


| Copyright ©2016 | All Rights Reserved |
| Design by Uves Khan |

Free Web Hosting