Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.forge;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- // write your code here
- List<String> palabras = new ArrayList<String>();
- Scanner in = new Scanner(System.in);
- while (true){
- String nombre = "";
- System.out.println("Ingrese un nombre");
- nombre = in.nextLine().toUpperCase();
- if (nombre.equals("STOP") ){
- break;
- }
- palabras.add(nombre);
- }
- String temp = "";
- for (int i = 0; i <= palabras.size() -1 ; i++ ){
- if (temp != "" ) {
- if (temp.length() < palabras.get(i).length()) {
- temp = palabras.get(i);
- }
- //System.out.println("El nombre del indice " + i + " es "+ palabras.get(i) + " y es de tamaño " + palabras.get(i).length());
- }else{
- temp = palabras.get(i);
- }
- }
- System.out.println(" La palabra con mas caracteres es " + temp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement