|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

05-08-2008, 12:33 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
|
I really love this thread now. Oh dear, where others in our community.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 12:41 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
|
|
Originally Posted by Eranga
I really love this thread now. Oh dear, where others in our community.
Eranga.........Where are other Questionsssss..
__________________
sanjeev,संजीव
|
|

05-08-2008, 12:41 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
System.out.println(strObjThree == strObjOne);
System.out.println(strObjThree == strObjTwo);
System.out.println(strObjThree.equals(strObjTwo));
is the answer true,false,true
@SANJEEV
let me try for '==' vs equals
'==' compares the reference in case of Object. If both referring to same then true otherwise false
"equals" first compares the reference ( using '==' ) then any other logic afterwards
please let me know if i am wrong
__________________
Life was much better in 2021
|
|

05-08-2008, 12:45 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
I really love this thread now. Oh dear, where others in our community.
this thread will be biggest
Sanjeev your turn, ask the quiz
__________________
Life was much better in 2021
|
|

05-08-2008, 12:48 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Originally Posted by rjuyal
Sanjeev your turn, ask the quiz
Yes it's. It's your turn Sanjeev now.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 12:50 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Originally Posted by rjuyal
"equals" first compares the reference ( using '==' ) then any other logic afterwards
Actually equals() method compares the characters that make up a String object.
Even though process is different. It actually creates two char arrays and puts the characters of each String objects in separate array and then performs the comparison.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 12:57 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
|
|
Originally Posted by Eranga
Actually equals() method compares the characters that make up a String object.
Even though process is different. It actually creates two char arrays and puts the characters of each String objects in separate array and then performs the comparison.
Exactly Eranga.....
__________________
sanjeev,संजीव
|
|

05-08-2008, 01:02 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
See the advantage to get familiar with much better ways in coding. Our newbie can learn a lot on this thread too.
So where is the next question? 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 01:02 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
EQUALS CODE of STRING CLASS
if (this == anObject) {
return true;
}
if (anObject instanceof String) {
String anotherString = (String)anObject;
int n = count;
if (n == anotherString.count) {
char v1[] = value;
char v2[] = anotherString.value;
int i = offset;
int j = anotherString.offset;
while (n-- != 0) {
if (v1[i++] != v2[j++])
return false;
}
return true;
}
}
return false;
anyways... next question please

__________________
Life was much better in 2021
|
|

05-08-2008, 01:04 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
|
Yep, nice work pal. If anyone can write similar application that libraries done, we can lean a lot. When I start work on Java I do this.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 01:08 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 251
|
|
|
Yeah, "yes" should be printed.....
__________________
best regards, 
sukatoa
|
|

05-08-2008, 01:09 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
|
original code
I didn't wrote this code, i just did a CtrlC CtrlV from String Class Code 
__________________
Life was much better in 2021
|
|

05-08-2008, 01:10 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Hey, hey.... 
You should mentioned there. Anyway nice work.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 01:12 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
|
One more
One more in this Thread, sukatoa welcome
and post some Quiz here
__________________
Life was much better in 2021
|
|

05-08-2008, 01:15 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
Yes, Sukatoa you can join with us. Just make a quiz and send it to here. But don't use any IDE for answering. Used only for write your question.
Seems Sanjeev try to make us a big trouble. May be he's designing a much better question for us.  
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 01:17 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
|
__________________
Life was much better in 2021
|
|

05-08-2008, 01:29 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
|
Once More
public class OneMoreEasyOne {
public static void main(String[] args) {
int a = 5;
System.out.println("Value is: - " + ( ( a > 5 ) ? 2.3 : 2) );
}
}
What will it print?
__________________
Life was much better in 2021
|
|

05-08-2008, 01:31 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
|
|
I think it should be,
What you give me this time. 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best? Vote Now
|
|

05-08-2008, 01:35 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
|
|
Originally Posted by Eranga
I think it should be,
What you give me this time. 
Value will be 2, because a > 5 is false, a >= 5 is true
__________________
sanjeev,संजीव
Last edited by sanjeevtarar : 05-08-2008 at 01:37 PM.
|
|

05-08-2008, 01:36 PM
|
 |
Member
|
|
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
|
|
|
and i thought!
i thought Eranga can't be wrong
But this time you are 
BTW, what's the logic behing 2.3
i will post the answer with reason after this 
__________________
Life was much better in 2021
|
|
| Thread Tools |
|
|
| Display Modes |
|
| | |