Answer to Question #3490 in Java | JSP | JSF for Y mukundareddy

Question #3490
Write a program to find the character at 6th place in the following string?
String str=”Hello world”
1
Expert's answer
2011-08-16T11:54:15-0400
import java.io.*;


public class Character6Finder
{
public static void main(String[] args) throws IOException
{
BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the string: ");
String inputStr = bReader.readLine();
if (inputStr.length() >= 6)
System.out.println("The 6th of this string = '" + inputStr.charAt(5) + "'");
else
System.out.println("The string contains less than 6 characters");
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS