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

Click For Summary
SUMMARY

The discussion centers on a Java programming issue where the user attempts to use a non-existent method called "subscript" on a String object. The correct method is "substring," which is part of the Java String class. The user receives a compilation error stating "cannot find symbol - method subscript(int,int)" and later acknowledges the mistake after clarification. This highlights the importance of understanding Java's String methods and their correct usage.

PREREQUISITES
  • Java programming fundamentals
  • Understanding of Java String class methods
  • Basic debugging techniques in Java
  • Familiarity with Java development environment setup
NEXT STEPS
  • Review Java String class documentation, focusing on the substring method
  • Practice Java string manipulation techniques
  • Explore common Java compilation errors and their resolutions
  • Learn about Java IDE features for debugging and error detection
USEFUL FOR

Java developers, programming students, and anyone looking to enhance their understanding of string manipulation in Java.

1/2"
Messages
98
Reaction score
0

Homework Statement


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;
System.out.println(m.subscript(b,a));
}
}


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:
Physics news on Phys.org
1/2" said:

Homework Statement


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;
System.out.println(m.subscript(b,a));
}
}


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

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
 
Yes it was substring . Thanks:smile:
I feel so stupid:blushing: for making such a silly mistake!:-p
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K