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?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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.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?displayLetter(string1.charAt(4)) wont work
How is displayLetter defined?
Is it: displayLetter(char c)
Last edited by Norm; July 4th, 2011 at 05:39 PM.
displayLetter(String1.charAt(4)) actually does work!!
cheers