Tom Hass

Greenhorn
+ Follow
since Jan 22, 2010
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 Tom Hass

Cheers Justin. I overlooked the main method. Silly me.
Hi Guys,




I was practising with the following code but had a problem during compilation. The compiler says;

"error: unreported exception IOException; must be caught or declared to be thrown".

Please what could be the problem here?
Thanks Campbell. Obviously, my only post, can't be compared to your over 15,000 posts so far.
11 years ago

raul saini wrote:When we say arrays and Strings are immutable, what does it actually mean?

Thank You



It means that they can't change their state after creation. Remember that Arrays and Strings are objects. A typical example would be 'String' (which is immutable) and 'StringBuffer or StringBuilder' (which are mutable).

Practical eg:

String s1 = "Joe";
String s2 = "Blog";

s1 += s2;

System.out.println(s1); // The s1 reference variable still retains its value as "Joe". In other to effectively add the s2 to s1, another String object needs to be created
//in other to effectively add the two objects together.

String s3 = s1 + s2; //which now contains the value: "Joe Blogs".

This is different to the other more specialised String classes such as StringBuilder and StringBuffer - which are mutable. (Use StringBuffer for Thread-safe operations).

Example:

StringBuilder sb = nee StringBuilder("Joe");

sb.append("Blogs"); // At this stage, the value of sb is "Joe Blogs".


11 years ago