4.20 (Process a string) Write a program that prompts the user to enter a string and displays
its length and its first character.
import java.util.Scanner; public class ProgrammingEx4_20 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter some string:"); String s = input.nextLine(); System.out.println("The string length is " + s.length()); System.out.println("The first character is " + s.charAt(0)); } }
this answer came up hella wrong
ReplyDelete