Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SubString PROBLEM. HELP ASAP!!!

 
Gabriel Collet
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.

I�m kind of a newbie. I�m trying to use the function subString in the following way but haven�t been able to make it work


String nom=sb.subString(4);

where nom has been defined at the beginning as a public String and sb is a stringbuffer with the string of information i want to divide into substrings.

This is the error message I get.

cannot resolve symbol
symbol : method subString (int)
location: class java.lang.StringBuffer
String nom=sb.subString(4)

PLEASEEEEE, CAN ANYONE GIVE ME A HAND OR SEND ME AN APPLICATION WHERE THIS WORKS!!!
THANKS
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you've misspelled "substring". note, no capital letters.

the easiest and quickest way to fix this sort of problems, i've found, is to go looking in the Java API documentation for the class or method you want to use. it's amazing what you can find in there!
[ February 15, 2005: Message edited by: M Beck ]
 
Liam Tiarnach
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



This is the error message I get.

cannot resolve symbol
symbol : method subString (int)
location: class java.lang.StringBuffer
String nom=sb.subString(4)

PLEASEEEEE, CAN ANYONE GIVE ME A HAND OR SEND ME AN APPLICATION WHERE THIS WORKS!!!
THANKS


Remember, Errors are your friends...

The error states, "Hey dude, I can't resolve this symbol... You said it's a method called subString, but looking at java.lang.String buffer, I can not find a method with that signature... what gives? by the way here is your code... String nom=sb.subString(4) check spelling or something"

so let take a look at the java.lang.StringBuffer API...

and what do you know, there is no subString(int) method, in this case its because looking at the API, the method name substring is all in lowercase... Which is funny, because one would think that having the first letter of the second word in the method name capitalized would follow the accepted coding conventions... but go figure...

Hope this helps...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please take a look at both http://faq.javaranch.com/view?EaseUp and http://faq.javaranch.com/view?KeepItDown - thanks!
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Liam Tiarnach:

and what do you know, there is no subString(int) method, in this case its because looking at the API, the method name substring is all in lowercase... Which is funny, because one would think that having the first letter of the second word in the method name capitalized would follow the accepted coding conventions... but go figure...


Depends on whether you count "sub-string" as one word or two; sub is not a true word in and of itself; it is simply a morpheme meaning "under" or "lesser." As such, it is one word. (you wouldn't write a method called subMarine() or subJugate()...)

On the other hand, I always write subString and the compiler has to tell me "no, no, no" , so there you go.
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joel McNary:
Depends on whether you count "sub-string" as one word or two; sub is not a true word in and of itself; it is simply a morpheme meaning "under" or "lesser." As such, it is one word. (you wouldn't write a method called subMarine() or subJugate()...)


well, no, but somebody did decide to write a String.subSequence(), so...
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, would you apply the same logic to "System.arraycopy"? I do consider substring to be a single word, however -- subsequence too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic