0
A Java program used the first letter of the given word .
Java program
2 Réponses
+ 4
String word = "hello";
char letter = word.charAt(0); // letter is 'h'
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
String word = "";
char ch='\0';
System.out.println("Enter the word.");
Scanner sc = new Scanner(System.in);
word = sc.next();
for (int i=0;i<word.length();i++)
ch = word.charAt(0);
System.out.println(ch);
}
}