Trying to compile the following code:
public static void main(String args[])
{
try
{
RandomAccessFile r = new RandomAccessFile("rtest.txt","rw");
}
catch (FileNotFoundException e)
{
}
try
{
r.seek(0);
}
catch (IOException e)
{
}
}
...produces the following error...
--------------------------- Compiler Output ---------------------------
HelloWorld.java:20: cannot resolve symbol
symbol : variable r
location: class HelloWorld
r.seek(0);
^
1 error
Is it because the scope of the object referenced by r is limited to within the curley braces of the first try/catch statement?