John Dell'Oso

Ranch Hand
+ Follow
since Apr 08, 2004
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 John Dell'Oso

Brandon,

In addition to the useful advice already given, I would suggest also using an array for your collection of rooms. In fact a collection class such as ArrayList would be even better. That way you can deal with any number of rooms instead of a fixed number of 5. I'm not sure how far along the Java "learning curve" you are, so if you have yet to learn about these data structures, then continue along the line you are currently on in conjunction with the advice already provided.

Good luck.

JD
14 years ago
Static blocks aren't constructors. These blocks of code are executed only if required - that is when a static method or field of the class is accessed or if an object is being created for the first time. In your example, the object of type Two is being created - it's super class is Super, so its static block is executed, then control passes back to the Two class and its static block is executed - this results in the output you're observing.

I've been out of the Java "loop" for a while - I'm sure someone will correct me if I'm wrong or articulate a better response.

Regards,
JD
15 years ago
Hello,

I recently downloaded and installed Eclipse Europa (3.3.1.1).

Yesterday, I tried to use the Help application (via Help --> Help Contents) and received the following error:

HTTP ERROR: 500
Unable to compile class for JSP
RequestURI=/help/advanced/help.jsp

Powered by Jetty://

I've checked the Error Log view and there are no messages logged.

I have found that I can finally get the Help to work by either:

1. continuously executing the application until it displays correctly - usually takes 5 or 6 tries, or

2. fire up the Dynamic Help and then try to bring up the Help Contents - this usually takes a couple of tries.

Has anyone experienced this behaviour?

Regards,
JD
When attempting to compile BeerSelect, it can't find the BeerExpert class. Try adding .\classes to your -classpath when compiling BeerSelect.

Regards,
JD
16 years ago
Peter,

I have changed your method to the following (sorry, the code is a little messy and I got a little lazy with catching the UnsupportedEncodingException that can be thrown by the getBytes method, so I'm just throwing the Exception - but hopefully you get the picture):



For example if you pass the string "ABCD", the method will return the following array of shorts:
-2
-1
0
65
0
66
0
67

The -2 and -1 values represent the xFEFF byte order mark which is big-endian UTF-16. If you don't want the byte order mark, then change the encoding in the getBytes method to "UTF-16BE".

Is this the sort of thing you were looking for?

Regards,
JD
16 years ago
Good point Marc, Whoa .. it's the early hours of the morn' here in Oz. Not in my Java as well. Both output statements are true.

Cheers,
JD
16 years ago
The reason:

Because that's the way an exclusive OR works. If both operands are true and false, then the result is true. If both operands are the same (either false or true), then the result is false.

There's no difference between your first and second output statements. In the first statement you are using the Java keywords of false and true and in the second statement, you are setting fields to each of these reserved key words (values).

Do a little research on boolean logic and truth tables.


Regards,
JD
[ August 03, 2007: Message edited by: John Dell'Oso ]
16 years ago
Have a look at this:



The second constructor is expecting a byte. You have to use a cast as the literal 4 is assumed to be an integral type.

Regards,
JD
[ August 01, 2007: Message edited by: John Dell'Oso ]
16 years ago
Tim,

Have a look at the List type classes - ArrayList or LinkedList. These classes have the necessary functionality to suit your requirements. However, if you're talking about millions of "records", you may run into resource and/or performance issues. Without knowing all the details of what you're trying to do, this sort of requirement suggests the use of a database of some sort.

Regards,
JD
16 years ago
In the first example, you're not breaking out of the for loop (you're just breaking out of the statement body), whereas in the second example you are breaking right out of the for loop.

Regards,
JD
16 years ago
In the Java API documentation, take a look at the BigInteger and BigDecimal classes.

Regards,
JD
16 years ago
Hello,

You've compiled the class with JDK 1.5.x and are probably trying to run it with a JVM 1.4 version. Without knowing your environment, I would only be guessing where it's finding a reference to this java runtime.

Regards,
JD
16 years ago
If the condition (current != null) is true, then the method returns true, otherwise it returns false.

Regards,
JD
16 years ago
Pratap,

Is there anything in particular that you don't understand? Were you expecting the output to be different?

Regards,
JD
16 years ago
Perhaps this old JavaRanch thread on the same topic may help you.

Are statics inherited?

Regards,
JD
16 years ago