Today I finally finished the Purse code. I had a little trouble with it in the beggining because I was confused at if the string was an object or a class.
We also took a note informing us about datatypes and other things which made Java a lot clearer.
In Turing, string is a primitive (read: basic) datatype. In Java, String is a class, and so every String is an object of that class.
ReplyDeleteThis is a significant difference! Amongst other things, it means that methods can be called against Strings. For example, you can ask a String its length:
String studentName = "Fahim";
System.out.println("Your name is " + studentName.length() + " characters long");