0

A Java program used the first letter of the given word .

Java program

14th Feb 2017, 7:07 AM
gourav
gourav - avatar
2 Réponses
+ 4
String word = "hello"; char letter = word.charAt(0); // letter is 'h'
14th Feb 2017, 7:25 AM
Kawaii
Kawaii - avatar
+ 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); } }
14th Feb 2017, 7:35 AM
Varun Moghe
Varun Moghe - avatar