lee dalais

Ranch Hand
+ Follow
since Feb 28, 2001
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by lee dalais

hi there
this is from the java docs:
public StringBuffer(String str)
Constructs a string buffer so that it represents the same sequence of characters as the string argument; in other words, the initial contents of the string buffer is a copy of the argument string. The initial capacity of the string buffer is 16 plus the length of the string argument.
str - the initial contents of the buffer.
hi there
so what's the questions, the while loop will be executed because b=1 is greater than 0.
hi mansoor
this is what i think:
String str="String"; //gets put into a string pool
str.toString() //returns 'String', but 'String' is already in string pool
"String".toString() // returns 'String', but 'String' is already in string pool
so they both have reference to the same string, so '==' returns true.
2.it seems that with this, both statements
"String".replace('g','G') check the string pool and find that there is no matching string, so they both return different references. so unequal.
if u said ("String".replace('g','G')).intern() to both it would return equal as they would both be put in the string pool but the strings are the same so they would both refer to onw string so same reference.
3.with this, both statements
("String".replace('t','t') check the string pool and find a matching string so they both return the same reference, so equal
[This message has been edited by lee dalais (edited March 30, 2001).]
hi Mudassar
thnx for the insight
hi there
this is from the java docs
"An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
hi gayathri
i think that the answers are right, when a thread executes, it is in the running state, so it is in the run() method, those methods may cause the thread to stop executing, taking it out of the running state, meaning stopping it from executing the run() method.
'stop executing' doesn't mean thread is dead!
anyone pls correct where i'm wrong
hi Tanveer
when u specify "this" it refers to the current object and u have overriden the method func() in the subclass, so since u created an instance of the sub it refers to instance 'i', so in other words i.func();.
anyone pls correct where i'm wrong.
thanks sean for the correction, i reassesed/reread what i wrote and realized that i was describing the wrong method.
thank u again
hi Shah
from my understanding:
what interrupt() does is that it temporarely suspends the currently running thread, to give the thread schedular a chance to check if there are any other threads(generally higher priority threads) that it can put into the running state, if not, then the currently running thread carries on running.
hi shabbir
there were a few more errors so here is the compileable code and the return f; statement should be in the finally clause as the compiler sees the return statement after the finally clause even though u've put the same return statement in the try block. so the compiler sort expects an exception to occur because u've put in try catch and finally blocks but if an exception does occur the finally block shoudn't be run as u have a return statement in the catch block, but if u didn't have the return statement in the catch block only the finally block will be run but the return was after the finally block.
hope this is clear
here's the correct code:
public class tester{
public float parseFloat(String s){
float f = 0.0f,f1=0.0f;
f = Float.valueOf(s).floatValue();
return f;
catch(NumberFormatException fex){
System.out.println("Invalid input" + s);
f1 = Float.NaN;
return f1;
finally{ System.out.println("finally"); return f;}
hi mansoor
i not 100% sure, but i tried it and got a compile error saying "illegal start of statement/expression" or something like that.
so i think that u cannot declare a new method inside a method.
hi ego
this is from the JLS:
An inner class is a nested class that is not explicitly or implicitly declared static.
static classes declared inside another class are referred to as a nested classes.
hi there
u have defines the method2() inside the main() method,
that seems to be the problem.
i think the answers are 1 and 5 are true.
when using the "==", u are comparing references not content.
and yes string are immutable.