String String1 = new String();
String1 = "bubble";
String1.charAt(4);
I want to input the result of String1.charAt(4); which is the letter l into a method which only takes a char as an argument.
What line of code is required?
Printable View
String String1 = new String();
String1 = "bubble";
String1.charAt(4);
I want to input the result of String1.charAt(4); which is the letter l into a method which only takes a char as an argument.
What line of code is required?
I tried:
String1.charAt(4) = char aChar;
I get: Syntax error: column 21. Encountered: char
What does the String charAt() method return?
String1.charAt(4) should work as is.Quote:
a method which only takes a char as an argument.
What were you trying to do with this: String1.charAt(4) = char aChar;
It looks reversed from what it should be.
String1.charAt(4) should work as is. Yes it does, it returns the letter l, but then how do i input this result into another method that only takes a char as an
argument.
displayLetter(String1.charAt(4)) wont work , so what coding do i need? How do i assign the result to a value that displayLetter() can take as an argument?
Have you tried it?Quote:
displayLetter(string1.charAt(4)) wont work
How is displayLetter defined?
Is it: displayLetter(char c)
displayLetter(String1.charAt(4)) actually does work!!
cheers