Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A question about equals  RSS feed

 
Gnome986
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[code]
Which methods can be legally applied to a string object?
a.equals(String)
b.equals(Object)
c.trim()
d.round()
e.toString()
the answer is a b c d e
my question is focus on a.
because i have viewd the api for jdk1.3 and i merely find the method of equals(Object obj) at the the class of String.So i think the answer shouldn't include a.
my english is poor so i don't know if i explain clearly.
 
Scott Appleton
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A String "is an" Object and is therefore a legal argument to any method which takes an Object as a parameter.
 
Junilu Lacar
Sheriff
Posts: 10878
158
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, d is incorrect. You cannot round() a String.
 
Gnome986
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gnome986,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
http://www.javaranch.com/name.jsp

Thanks for your cooperation.

------------------
Co-Moderator of the Programmer Certification Forums
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!