Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





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.

Reply
 
LinkBack Thread Tools Display Modes
  #41 (permalink)  
Old 05-08-2008, 12:33 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #42 (permalink)  
Old 05-08-2008, 12:41 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by Eranga View Post
I really love this thread now. Oh dear, where others in our community.
Eranga.........Where are other Questionsssss..
__________________
sanjeev,संजीव
Bookmark Post in Technorati
Reply With Quote
  #43 (permalink)  
Old 05-08-2008, 12:41 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
Code:
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
Bookmark Post in Technorati
Reply With Quote
  #44 (permalink)  
Old 05-08-2008, 12:45 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
PHP Code:
I really love this thread nowOh dearwhere others in our community
this thread will be biggest



Sanjeev your turn, ask the quiz
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #45 (permalink)  
Old 05-08-2008, 12:48 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by rjuyal View Post


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
Bookmark Post in Technorati
Reply With Quote
  #46 (permalink)  
Old 05-08-2008, 12:50 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by rjuyal View Post
"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
Bookmark Post in Technorati
Reply With Quote
  #47 (permalink)  
Old 05-08-2008, 12:57 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by Eranga View Post
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,संजीव
Bookmark Post in Technorati
Reply With Quote
  #48 (permalink)  
Old 05-08-2008, 01:02 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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
Bookmark Post in Technorati
Reply With Quote
  #49 (permalink)  
Old 05-08-2008, 01:02 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
EQUALS CODE of STRING CLASS

Code:
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
Bookmark Post in Technorati
Reply With Quote
  #50 (permalink)  
Old 05-08-2008, 01:04 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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
Bookmark Post in Technorati
Reply With Quote
  #51 (permalink)  
Old 05-08-2008, 01:08 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 251
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Yeah, "yes" should be printed.....
__________________
best regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #52 (permalink)  
Old 05-08-2008, 01:09 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
original code
I didn't wrote this code, i just did a CtrlC CtrlV from String Class Code
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #53 (permalink)  
Old 05-08-2008, 01:10 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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
Bookmark Post in Technorati
Reply With Quote
  #54 (permalink)  
Old 05-08-2008, 01:12 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
One more
One more in this Thread, sukatoa welcome

and post some Quiz here
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #55 (permalink)  
Old 05-08-2008, 01:15 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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
Bookmark Post in Technorati
Reply With Quote
  #56 (permalink)  
Old 05-08-2008, 01:17 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
PHP Code:
Seems Sanjeev try to make us a big troubleMay be hes desig 
lol
__________________
Life was much better in 2021
Bookmark Post in Technorati
Reply With Quote
  #57 (permalink)  
Old 05-08-2008, 01:29 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
Once More
Code:
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
Bookmark Post in Technorati
Reply With Quote
  #58 (permalink)  
Old 05-08-2008, 01:31 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,136
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think it should be,

Code:
Value is - 2.3
What you give me this time.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best?Vote Now
Bookmark Post in Technorati
Reply With Quote
  #59 (permalink)  
Old 05-08-2008, 01:35 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Mumbai(India)
Posts: 230
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by Eranga View Post
I think it should be,

Code:
Value is - 2.3
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.
Bookmark Post in Technorati
Reply With Quote
  #60 (permalink)  
Old 05-08-2008, 01:36 PM
rjuyal's Avatar
Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 92
rjuyal is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes