Java: how to access assignments in try-catch -loop?
Posted
by HH
on Stack Overflow
See other posts from Stack Overflow
or by HH
Published on 2010-04-13T17:16:21Z
Indexed on
2010/04/13
17:23 UTC
Read the original article
Hit count: 336
$ javac TestInit2.java
TestInit2.java:13: variable unknown might not have been initialized
System.out.println(unknown);
^
1 error
Code
import java.util.*;
import java.io.*;
public class TestInit2 {
public static void main(String[] args){
String unknown;
try{
unknown="cannot see me, why?";
}catch(Exception e){
e.printStackTrace();
}
System.out.println(unknown);
}
}
© Stack Overflow or respective owner