• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

SubString PROBLEM. HELP ASAP!!!

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Normally trees don't drive trucks. Does this tiny ad have a license?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic