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
  #121 (permalink)  
Old 05-13-2008, 08:40 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
Eranga
Quote:
but found a String object there in the second println().
What about the first line?
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #122 (permalink)  
Old 05-13-2008, 08:47 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ah, the first line too. How I miss it
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #123 (permalink)  
Old 05-13-2008, 08:50 AM
Member
 
Join Date: May 2008
Posts: 22
Jesdisciple is on a distinguished road
I must have read to the end of the first page rather than the end of the thread. Disregard that post.
Bookmark Post in Technorati
Reply With Quote
  #124 (permalink)  
Old 05-13-2008, 09:02 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, in such cases quote the original message and make your comments.

Actually I don't think start from the beginning is much easy now. Just join with the current discussions.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #125 (permalink)  
Old 05-13-2008, 09:12 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
Eranga
Quote:
first line too. How I miss it
NumberFormatException

Code:
public Integer(String s) throws NumberFormatException { this.value = parseInt(s, 10); }
Even the constructor uses that static method parseInt
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #126 (permalink)  
Old 05-13-2008, 09:15 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yep, I got the point pal. Thanks for the hidden error. See how much we learn on this.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #127 (permalink)  
Old 05-13-2008, 09:28 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
Once more

Code:
package com.faaltu.ObjectTest; public class ObjectReferenceTest { ObjectReferenceTest objectReferenceTest; public int x; public static void main(String[] args) { ObjectReferenceTest objectReferenceTest = new ObjectReferenceTest(); objectReferenceTest.x = 20; System.out.println(objectReferenceTest); myFunction ( objectReferenceTest ); System.out.println(objectReferenceTest); } static void myFunction( ObjectReferenceTest objectReferenceTest ){ System.out.println("BEGIN ObjectReferenceTest.myFunction()"); System.out.println(objectReferenceTest); objectReferenceTest = new ObjectReferenceTest(); objectReferenceTest.x = 40; System.out.println(objectReferenceTest); System.out.println("END ObjectReferenceTest.myFunction()"); } public String toString() { return "x: " + x; } }

guess the output ?
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #128 (permalink)  
Old 05-13-2008, 09:44 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Oops, it's too long to work on mind pal. Keep short next time Let me try.

From main function,

x: 20

From myFunction

BEGIN ObjectReferenceTest.myFunction()
x: 20

After this point value of x changed.

x: 40
END ObjectReferenceTest.myFunction()

From main function,

x: 20

So, for me it's ok. No compile errors. Am I correct?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #129 (permalink)  
Old 05-13-2008, 10:12 AM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
yes you are always
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #130 (permalink)  
Old 05-13-2008, 10:32 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
All these practice comes because of the notepad. I start to work on with it in the past. So I have to care of each line in my code.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #131 (permalink)  
Old 05-13-2008, 10:52 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Here is the next one.

What's the output of this.

Code:
System.out.println("The answer is: "+11+9);
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #132 (permalink)  
Old 05-13-2008, 10:54 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 160
Eku is on a distinguished road
The answer is: 20

I think. =)
Bookmark Post in Technorati
Reply With Quote
  #133 (permalink)  
Old 05-13-2008, 10:56 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 160
Eku is on a distinguished road
The answer is: 20

Its just a wild guess. . . =P Ive tried returning a equation in a function. So i think its the same thing around in System.out. It will sum it up first. If both are numbers it will treat the "+" sign as a part of the equation not a delimeter. Correct me if Im wrong.
Bookmark Post in Technorati
Reply With Quote
  #134 (permalink)  
Old 05-13-2008, 11:01 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
You are wrong my friend. It's all about string concatenations. Since you don't have think about parameter presidencies the output is,

Quote:
The answer is: 119
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #135 (permalink)  
Old 05-13-2008, 11:05 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 160
Eku is on a distinguished road
^_^ I see. . . One point to a new Knowledge.
Bookmark Post in Technorati
Reply With Quote
  #136 (permalink)  
Old 05-13-2008, 11:11 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think you know how to correct it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #137 (permalink)  
Old 05-13-2008, 11:19 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 160
Eku is on a distinguished road
I know now. Thanks for the Knowledge my friend. =P
Bookmark Post in Technorati
Reply With Quote
  #138 (permalink)  
Old 05-13-2008, 12:10 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 502
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Here is another one,
Code:
public class Null { public static void ehem() { System.out.println("I am who am."); } public static void main(String[] args) { ((Null) null).ehem(); } }
Without compiling the said code, what should be the output?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #139 (permalink)  
Old 05-13-2008, 12:17 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
somthing like, Static method can not be called with object
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #140 (permalink)  
Old 05-13-2008, 12:17 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think output is,

Quote:
I am who am.
As far as I remember you used unsafe accessing to static field there. Am I correct?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes