- Aug 31, 2002
- 191
- 0
- 0
Alright, I'll admit, this is for an assignment that's due tomorrow. I *think* that I know how to do it, but Java is giving me an error on something that I'm *almost* completely sure is right. Without letting anyone help me cheat on my program, here's the snippet that's irking me:
Keyboard kbd = new Keyboard();
String s = kbd.getString("Input a word/phrase:");
int ls = s.length();
System.out.println(s.subString(ls - ls));
This has been dumbed-down so as to be completely useless in my program, as I only wish to know what the heck is wrong with my syntax.
Line by line, this creates an object of type Keyboard. It then creates a String that consists of the input taken by kbd. Integer ls is the length of String s, and subtracting it from itself is an ugly way of printing the entire String through the subString function.
Keyboard.class is a class provided by our professor to aid us in getting user inputs. You'll have to take my word for it that it isn't the culprit, as I'm able to print user inputs using that same code. Java is returning the error:
cannot resolve symbol
symbol: method subString (int)
location: class java.lang.String
System.out.println(s.subString(ls - ls));
^
Any help that anyone could offer would be greatly appreciated. If you'd like more information, I'll be checking this pretty often, as I'm in panic-mode right now, so don't be afraid to ask.
Thanks guys/gals!
Keyboard kbd = new Keyboard();
String s = kbd.getString("Input a word/phrase:");
int ls = s.length();
System.out.println(s.subString(ls - ls));
This has been dumbed-down so as to be completely useless in my program, as I only wish to know what the heck is wrong with my syntax.
Line by line, this creates an object of type Keyboard. It then creates a String that consists of the input taken by kbd. Integer ls is the length of String s, and subtracting it from itself is an ugly way of printing the entire String through the subString function.
Keyboard.class is a class provided by our professor to aid us in getting user inputs. You'll have to take my word for it that it isn't the culprit, as I'm able to print user inputs using that same code. Java is returning the error:
cannot resolve symbol
symbol: method subString (int)
location: class java.lang.String
System.out.println(s.subString(ls - ls));
^
Any help that anyone could offer would be greatly appreciated. If you'd like more information, I'll be checking this pretty often, as I'm in panic-mode right now, so don't be afraid to ask.
Thanks guys/gals!
