Jon Huhtala

Greenhorn
+ Follow
since Apr 10, 2002
Merit badge: grant badges
For More
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 Jon Huhtala

Are there any other Java professionals out there that are "geeky" enough to also be licensed amateurs?
- N8ZH
20 years ago
Good point, Ramki. The string literal will remain but the Double object will be garbage collected.
Karin,
Technically the object that was constructed by the
new Double("123.45)
is "eligible" for garbage collection immediately after the statement is executed. There is no way to tell exactly when the JVM will dispose of the object. It does it when it is darn good and ready...
Sekhar,
Only one String object is created. The compiler generates a String object in the literal pool for every literal string, such as "abcd". The variables s and s1 are merely references to the same String object. If, however, you had coded:
String s1 = new String(s);
A new String object would have been instantiated.
For more information, see
java-help.com
[ December 05, 2002: Message edited by: Jon Huhtala ]
Peter, give this a try:
String dl =
new Integer(cab.getDeckLevel()).toString();
This wraps the int within an Integer "wrapper" and calls the object's toString() method to return a String.
I have more information on wrapper classes on the Web at:
Java-help.com
[ October 29, 2002: Message edited by: Jon Huhtala ]
21 years ago
I am constructing a free Web site
java-help.com
that is aimed at preparing Java newcomers for the 1.2 exam (the one with GUI and file I/O). It is also used by my Java students at Ferris State University.
The site is about 50% complete and should be done by early December. I am open to comments about the site and am particularly interested in knowing if anyone would like to get 6 college credits while preparing for their certification. The tuition cost hasn't been worked out yet, but my guess is about $200 U.S. per credit hour ($1,200). Everything would be done over the Internet. Of course, the material is free for anyone not interested in college credit.
Hema,
The BIG difference is that String objects are immutable (can't be changed) while StringBuffer objects are mutable (can be modified).
If your application requires making a slight modification to the value of an existing string or expanding an existing string, you might consider StringBuffer. If you use String, a new String object must be constructed every time you want to make a change to the string.
[ June 26, 2002: Message edited by: Jon Huhtala ]
21 years ago
Questions involving wrapper classes did appear on my exam about 10 days ago. Key points to remember are that wrapper objects are immutable and their toString() method allows concatenation with other strings. For example,
Integer someNum = new Integer(15);
System.out.println("Number is " + someNum);
will display "Number is 15".
They are also handy for string <-> primitive conversion, displaying the hexadecimal string for an integer, etc..
Congrats, Oscar!
After all that work, it sure feels good, doesn't it?
Best of luck...
22 years ago
I took the test last week and had NO questions on Applets, HTML, and painting. It surprised me because I had been studying these topics and saw them on mock exams too.
I guess it doesn't hurt to be prepared, though.
Travis,
If those scores are in sequence, you're probably ready if they were done in well under the 2 hour limit. For me, and some others I've talked to, the real test will slow you down.
If you think you're ready, go do it!
Here is a portion of an applet assignment I gave my students to help them calculate the number of days between two dates using J++. It should give you some ideas:
Create a class named MyCalendar that extends GregorianCalendar for the purpose of accessing the protected getTimeInMillis( ) method. The code for this class is as follows:
import java.util.*;
public class MyCalendar extends GregorianCalendar
{
public MyCalendar()
{
super();
}
public long toMillis()
{
return getTimeInMillis();
}
}
To calculate and display information about a particular date in the future or in the past (as far back as January 1, 1970), your applet must contain a text field in which the user may enter the target date as a String in English. You will need to convert this String to a MyCalendar object in order to perform date processing. For example, the following code could be used (assuming the reference of the text field object is targetDateField):
DateFormat localDate = DateFormat.getDateInstance(DateFormat.SHORT,Locale.US);
MyCalendar targetDate = new MyCalendar();
try
{
targetDate.setTime(localDate.parse(targetDateField.getText().trim()));
}
catch (ParseException err)
{
}
This permits the date string to be entered in MM/DD/YYYY format (such as "10/15/1978"). The try and catch are needed to satisfy the compiler.
Calculating the number of days between two dates can be challenging when they are in different years. To do so, you need to convert each date into milliseconds, subtract to obtain their difference in milliseconds, then divide the result by the number of milliseconds in one day ( 24*60*60*1000 ). Be sure to use the toMillis( ) method of MyCalendar.
Hope this helps...
22 years ago
String is a class name and not a keyword. It is OK, but poor coding technique, to use it as a label.
Note that the inner loop does no printing. In fact it prevents the outer loop from printing when i+j is greater than 10 because it breaks to the next iteration of the outer loop. Printing only happens when i is 0 or 1 because j takes on values as high as 9 and forces the break.
Good work, Dan.
If you were like me, you were probably watching that little count-down clock and estimating that you weren't going fast enough. At least they haven't thought of adding a little TICK-TICK-TICK sound to really drive people nuts.
I think people preparing for the exam should be able to comfortably do the "mocks" in under an hour and a half (if not faster). Working in a strange environment under exam pressure will slow them down.
Congrats!
22 years ago
I took my exam yesterday and had about three or four "free response" questions. They were very specific - like what value a string would have after executing a snippet of code or what value an int variable would have after doing some bit manipulation.
Keep in mind that your answer will be computer evaluated. The questions, therefore, are VERY specific and only involve a single line to be typed by you. Do not put in any unnecessary keystrokes and remember case sensitivity.
If you've written a fair amount of code, these questions are like freebies...