Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A blue j string manipulation problem(its simple but still i can't figure it out)

  1. Dec 5, 2011 #1
    1. The problem statement, all variables and given/known data
    Well this actually a part of a different problem and there i want to make use of subscript function but its giving a funny problem .
    it's like this:
    public class test
    { void main(String m)
    { int a =m.length(),b=0;

    3. The attempt at a solution
    When i try to compile this it gives me an error " cannot find symbol - method subscript(int,int)"
    So it tried to declare a and b in separate lines and the are obviously int type.
    Please can you point out my mistake(It may be very silly ,i know)
    Thank you
    Last edited by a moderator: Dec 7, 2011
  2. jcsd
  3. Dec 7, 2011 #2


    Staff: Mentor

    There is no "subscript" method on the String class - are you thinking of the substring method? See http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html
  4. Dec 8, 2011 #3
    Yes it was substring . Thanks:smile:
    I feel so stupid:blushing: for making such a silly mistake!:tongue:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook