Sunday, February 15, 2015

CodeEval.com

Took a day off to tackel one of the harder problems on codeEval.com

This is my template for JAVA I have crafted.
Also, after messing with Java and JavaScript,
I say my interviewer was wrong saying that AS3 was more
like JavaScript than Java..

Java has no classes.
The syntax looks more similar yes...But classes are a huge thing for me.
Also, AS3 has the ability to strict type. Java does not.
And I like my variables typed.

Whatever. There are other ways to prove I am a good coder.


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


class Main
{
   
    //Class is uppercase, yet constructor function is
    //lowercase. I find this weird.
    public static void main (String[] args)
    {
   
        try {
            File file = new File(args[0]);
            BufferedReader in = new BufferedReader(new FileReader(file));
            String line;
            while ((line = in.readLine()) != null) {
                String[] lineArray = line.split("\\s");
                if (lineArray.length > 0) {
                    // Process line of input Here
                    System.out.println(line);
                }
            }
        } catch (IOException e) {
            System.out.println("File Read Error: " + e.getMessage());
        }              
    }
}

No comments:

Post a Comment