Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

using for each loop for searching in array

import java.util.Scanner;

public class Sample {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String names[] = { "Jasmine", "Lyka", "Marbie", "Soleen", "Tiny" };
        System.out.print("Enter name to search:");
        String search = input.nextLine();
        for (String name : names) {
            if (name.equalsIgnoreCase(search)) {
                System.out.println("We found " + name);
                break;
            } else {
                System.out.println(name);
            }
        }
        input.close();
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: .throwFor in java 
Java :: printing array in descending order 
Java :: Composite foreign keys as primary key jpa 
Java :: public class ForLoop { public static void main(String[] args){ for(int i=1; i=n ;i++ ) System.out.println("i"); } } 
Java :: computeifabsent hashmap java 
Java :: find maximum number of rides in amusement park python 
Java :: banner generator spring boot 
Java :: conexion a mysql java 
Java :: Sauvegarder une partie en cours dans un fichier texte java 
Java :: lcd initialize arduino 
Java :: a to double 
Java :: split the argument String and add the tokens into a list 
Java :: while(++i<5)f*=i;System.out.println(f); 
Java :: java remove numbers from set 
Java :: copy array of objects in java 
Java :: repository null when testing service 
Java :: Add Future Date in AndroidStudio 
Java :: bukkit shutdown 
Java :: how to use old android studio project 
Java :: The JCheckBox and JComboBox classes belong to which package? 
Java :: set default messaging app android manifest 
Java :: do switch statement always run default java 
Java :: using ..replace() in jShell/java 
Java :: Java Using Looping Construct to Copy Arrays 
Java :: print java object inherited classes 
Java :: how to check if rs next is null 
Java :: Java Method for Code Reusability 
Java :: using automapper without dependency injection 
Java :: java konsolenausgabe 
Java :: java csvformat example semi colon 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =