Chuck Lorenz

Greenhorn
+ Follow
since Jul 06, 2001
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 Chuck Lorenz

Will you get better results if you replace with ? I don't know from personal experience (too new to the API), but the short course from JGuru on the Fundamentals of the JavaMail API seems to imply it.

Transport
The final part of sending a message is to use the Transport class. This class speaks the protocol-specific language for sending the message (usually SMTP). It's an abstract class and works something like Session. You can use the default version of the class by just calling the static send() method:
Transport.send(message);
Or, you can get a specific instance from the session for your protocol, pass along the username and password (blank if unnecessary), send the message, and close the connection:
message.saveChanges(); // implicit with send()
Transport transport = session.getTransport("smtp");
transport.connect(host, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
This latter way is best when you need to send multiple messages, as it will keep the connection with the mail server active between messages. The basic send() mechanism makes a separate connection to the server for each method call.


Chuck
21 years ago
I passed today with an 86%.
You haven�t seen my name much in postings around here. I think I�m like many of the anonymous folks who have benefited from searching the postings and from the enthusiasm exhibited in the daily conversations. But I don�t want my thanks to go unheard.
Thank you Java Ranch � sheriffs, bartenders, ranch hands, greenhorns and all you cows that never seem to find your way into the corral.
The advice I found here regarding the exam was right on target. I have nothing to add. The two most important tools for me were JQPlus and JavaRanch � no flattery, just honesty.
Best wishes to you who are still studying, and �Don�t give up!� to you who have to give it another shot. As for me, I�m hooked on the Ranch, so maybe you�ll see my name from time to time.
Thanks again.
Chuck
21 years ago
Khalid Mughal posted the following on July 09, 2001 in the Programmers Certification Study forum in response to a similar question.
JLS quote:
"An anonymous class is never abstract (�8.1.1.1). An anonymous class is always an inner class (�8.1.2); it is never static (�8.1.1, �8.5.2). An anonymous class is always implicitly final (�8.1.1.2)."
If you look carefully you will see that the word "static" refers to the keyword in the above quote. I choose to interpret this as meaning that an anonymous class cannot be declared static (<--- keyword).
In our explanation, we are using the word "static" in the non-keyword sense of the word to indicate "an anonymous class declaration in a static context". As the examples presented in this discussion have shown, an anonymous class declared in a static context cannot access instance members in its enclosing context. This is the point we wanted to get across and the fact that such a class is instantiated without any outer object.
We will make sure that such confusion about terminology does not arise in any future edition of the book.
wbw,
khalid mughal
21 years ago
Hi Jane,
Thanks for the site reference. I'm fairly new to the Ranch, and this was my first visit to your site. It's great. Well organized; succinct. Very much appreciate your section on java.io. And tips and traps!
Thanks for your work.
Chuck
Sunil,
"value printed on the screen is one more than Integer.MAX_VALUE"
...try interpretting the phrase as
System.out.println((Math.abs(Integer.MAX_VALUE)); + 1
The range of int is -2147483648 to 2147483647.
Notice that the absolute value of Integer.MIN_VALUE is one greater then the absolute value of Integer.MAX_VALUE.
Chuck
Vanitha,
In another(), your comments say that assigning vh to v means v.i == 10 because it references a new Valhold object. Yet back in amethod(), your comments say the System.out.println(v.i) will print "20" due to the changes made in another(). Does not the reference to the new ValHold object supplant the change to 20, so that System.out.println(v.i) should print "10"?
Thanks,
Chuck