[ASAP] optimized code: max 8 semi colons
Hi
i need help getting rid of semi colons. Do you guys know of any tricks that i can use to get rid of semicolons. Such as initializing a variable without the use of a colon(via some trick). My professor said that is possible. It is also possible to get rid of the i/o import:
I have a impot java.util.*; and a Scanner x = new ... ;
How can I get rid of those 2 semi colons and stil read user input.
Thanks
[437 byte] By [
bobDylana] at [2007-11-27 4:36:10]

You can use the fully qualified classname instead of the import, but you must have some semi colons, and I don't see a reason to try to get rid of them. It just makes the code harder to read.Kaj
You could slim down by writing:
int i=17, j=42, k=1066;
instead of
int i = 17;
int j = 42;
int k = 1066;
or by using an array:
int[] vars = {17, 42, 1066};
> > > Sabre is the winner. :)
> >
> > And I didn't even have to use a regex!
>
> I bet you would have used regexp to find all
> occurences of ; in all files ending with java ;)
:-) Also in in the FileFilter used to select only those files ending in ".java" .
if (file.getName().matches(".*\\.java$")))
{
}
I know I could use String.endsWith() but real men use a regex whenever they can.