iBrasten

My methods of calculating time are far superior to yours, in every way.

 

This is the blog of Brasten Sager, a freelance software developer, Mariners fan, guitarist, haphazard philosopher.

Java and C#

May 24, 2005 @ 08:02 AM
Since I think I have roughly an equal number of Java supporters and .NET supporters reading this blog, I’ll now perform a completely pointless but interesting exercise.  As you probably know, I can’t write C# code.  However, it’s similar enough to Java that I can READ it.  So I’ve found a short little C# routine, and I’ll translate it into Java, and we can all look and wonder why I would waste my time doing such a thing.

C# Code:

using System;

public class CommandLine {
    public static void Main(string[] args) {
        Console.WriteLine("Number of command line parameters = {0}", args.Length);
        for (int i = 0; i < args.Length; i++) {
            Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
        }
    }
}


Java Code:

public class CommandLine {
    public static void main(String args[]) {
        System.out.println("Number of command line parameters = " + args.length);
        for (int i = 0; i < args.length; i++) {
            System.out.println("Arg[" + i + "] = [" + args[i] + "]");
        }
    }
}



Also, ignore the \’s in front of quotes. WordPress seems to want to add them in front of quotes inside <pre> tags, and I don’t care to figure out why at the moment.

0 Responses to “Java and C#”