Jean-Christian Imbeault

Greenhorn
+ Follow
since Dec 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
1
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 Jean-Christian Imbeault

Henry Wong wrote:
The reason is, since final variables do not change, and it is possible for the compiler to detect whether it has been initialized, that if so... it is allowed, because the inner class can make a copy of the variable.



Henry I like your answer in that both should be disallowed, final or not.

But I don't understand your second part. Even if the variable was not declared final the inner class could still make a copy, no?

Bert Bates wrote:Hey Guys,

Here's a 'thought experiment' that might help explain some of this behavior...

Consider that before Java 5 there was widening but not boxing. So, if you don't want old, working code to break, and you want to add boxing, what rules would you have to create?

hth,

Bert



Hi Bert and thanks for taking the time to post a reply. I totally agree that it's better to have us think through an answer to our questions rather than just giving us the answer. We're sure to remember and learn much better that way.

But for this one I really have to say that I just can't figure out why the behaviour in the original question is present.

To prevent old code from breaking you would need:

- widening should always win over boxing when a choice exist (lifted from your book, p.249)

But I can't figure out how this 'rule' creates the conditions that allow an int to be passed to method that expects a Short, but cause a compilation error when you try to declare and initialize a Short using an int.

If Short s = 4; is valid code then I would expect Car().test(4) to be also. But obviously I'm wrong

The following line:

System.out.println(3 + 7 + 5 + " ");

supposedly gives 15 as output.

While trying to figure out why I have read in other posts in this forum the two following (but opposite) views on the use of + for concatenation:

1- Whenever a Sring is present the + operator will evaluate all operands as Strings
2- Order of precedance is followed even when a String is involved, so in the above 3, 7, and 5 are all treated as int's (giving 15) before begin cast to a String.

So which is it? I'm pretty sure it's #2, but I have read many people posting things like #1 ....

Thanks.
If any of the authors have time, could you let me know your opinion on this thread?

https://coderanch.com/t/168724/java-Web-Component-SCWCD/certification/HF-SCJP-mock-exam-flush

I know it's nitpicky but I'd like to understand the details.
19 years ago
Hum ... so I wonder if this is a trick question?

Hopefully this kind of question where a 'well it's theoritically possible' answer doesn't come up on the exam
Chapter 5, page 209, mock exam question #1 asks:

"When using a requestDispatcher, the use of which method can often lead to an IllegalStateException (choose all that apply):

A. read
B. flush
C. write
D. getOutputStream
E. getResourceAsStream

The correct answer is given as B, but I would have though the answer should have been B *and* C.

Couldn't writing 'theoretically' cause the response to be commited and hence cause and IllegalStateException if we try and forward the request?

Or is it in the specification that nothing is sent to the browser until flush() is called or the servlet's service method returns?
Chapetr 5, page 209, mock exam question #1 asks:

"When using a requestDispatcher, the use of which method can often lead to an IllegalStateException (choose all that apply):

A. read
B. flush
C. write
D. getOutputStream
E. getResourceAsStream

The correct answer is given as B, but I would have though the answer should have been B *and* C.

Couldn't writing 'theoretically' cause the response to be commited and hence cause and IllegalStateException if we try and forward the request?

Or is it in the specification that nothing is sent to the browser until flush() is called or the servlet's service method returns?
Ok, but it's an empty directory. I've added exactly 0 in terms of information. Is the presence of this directory required by the specs? Even if empty?
19 years ago
You'll have to post a more detailed question in order to get good replies.

What kind of program? GUI, command line?

I'm assuming it's a GUI program. Have you written the GUI yet? Have you implemented the MenuBar?

There are some good tutorials out there on how to implement MenuBars in a Java GUI.
19 years ago
Got it!

This is what needs to be changed:

under Control Panel | Regional Options (General Tab)

my locale was set to Japan, I needed to set it to some english using locale (like US) *and* restart my windows machine.

I am happy to say that javac proudly displays my stupidity to everyone in a language I can understand
19 years ago
When I run javac I get compilation error thrown at me in Japanese. How can I tell javac to tell me I'm an idiot in english?

I've tried setting an environment variable called LANG to various things (C, en, eng, english) but nothing changes.

My windows command promt shell does display OS errors in english, but when I call javac, javac prints errors out in Japanese ...

My system is:

Windows 2000 (with japanese language installed)
j2sdk1.4.2_04

The following environment variables are set:

_OSLANG=ENGLISH
_OSLANG=ENGLISH
19 years ago
Thanks for the pointers.

In the spirit of trying to make the book better I'd like to point out a problem I had when trying the first code example in the book, the Beer advisor. I guess on pages 72 and 73 when you describe setting up the development and deployment environments you also meant 'We've explained it now set up both environments'.

The reason it wasn't clear to me that I needed to set up the directory structure at that point was that many of the folders mentionned (like classes/com/example/web) don't need to be created by me since they will be created when I compile the source code. Also you show not only folders but *files*. It's counter-intuitive to create files before the part in the book where you say what to put in each file. .

So when I tried to load up the form.html file after reading the instructions on page 76 that explicitly said to write it and where to put it, tomcat was throwing up a 404 error. This was because I had not created an empty WEB-INF directory.

Besides making the instructions a bit more explicit it would be nice to understand *why* a WEB-INF directory (even an empty one) is necessary when serving up plain html.

I'm loving the book so far and having to work through this problem actually made me understand things a bit more. It was just frustrating for the two hours I tried to figure it out by myself before asking for help

The full thread is here:

https://coderanch.com/t/359479/Servlets/java/Tomcat-error-HTML-file-Head
[ December 13, 2004: Message edited by: Jean-Christian Imbeault ]
19 years ago
That did it! Thanks.

Now my only question is why!? That is not something I would have expected. Why would a WEB_INF folder be needed is all you want to do is server up static pages?
19 years ago
I forgot to mention that I am running this with j2sdk1.4.2_06. Don't know if that make a difference or not as tomcat 5.5 needs java 1.5

I've even tried adding this file, C:\tomcat\webapps\test\a.txt and I cannot load that either using http://localhost:8080/test/a.txt

So it looks like I can not access anything I create under C:\tomcat\webapps, but the directories already there by tomcat (like jsp-examples) are accessible.
19 years ago