jerry cronin

Greenhorn
+ Follow
since Dec 19, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jerry cronin

I've fixed all the above errors I think, now I'm getting this last one

TinyTest.java:36: incompatible types
found : void
required: TinyTest
TinyTest test = new TinyTest().tryCatch();

Does this mean I must change the return type of tryCatch? And change the way its implemented

11 years ago
Here it is with tags!

11 years ago
I'm almost there now, but I'm getting an error at line 9 where i have current "<identifier> expected"
Thanks for all yer help so far as well!

import java.util.Scanner;
import java.io.*;

public class TinyTest
{
TinyToken current;
TinyScanner2 scanner = null;
TinyScanner2 scanner = new TinyScanner2(new FileReader("sample.tny"));
current = scanner.nextToken();

public static void tryCatch()
{
try
{
while(current != null)
{
System.out.printf (
"Token [%s]\n", current.toString());
current = scanner.nextToken();
}
}

catch(Exception e)
{
System.out.printf("error");
}

}



public static void main(String args[])
{
TinyScanner2 tinyScanner = new TinyScanner2().tryCatch();
}

}
11 years ago
What do you mean "current e scanner are duplicate variables."? I added in (Exception e) as well but im still getting the same error
11 years ago
Hi, I'm trying to implement a scanner but I'm getting multiple errors that are driving me mad I can't see the problem

I'm gettting "illegal start of type" at the try statement and at the while statement and "class interface or enum expected" at the catch statment
Any help is appreciated


[Added code tags - see UseCodeTags for details]
11 years ago