Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class a
- {
- static Scanner in = new Scanner(System.in);
- public static void main(String []args)
- {
- System.out.println("Enter your name");
- String name = in.next();
- String firstLetter = String.valueOf(name.charAt(0));
- System.out.println(firstLetter);
- System.out.println("Enter random letters");
- String random = in.next();
- for(int i = 0; i < random.length(); i++)
- {
- if(String.valueOf(random.charAt(i)).equals(firstLetter))
- {
- System.out.println("The first letter of your name is in position #" + i);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment