Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Array {
- public static void main(String[] args) {
- System.out.println(busca("b"));
- }
- static int busca(String nome) {
- List<Integer> _lista = new ArrayList<>();
- String lista[] = new String[5];
- lista[0] = "aaa";
- lista[1] = "bbb";
- lista[2] = "ccc";
- lista[3] = "ddd";
- lista[4] = "eee";
- for (int i = 0; i < 4; i++) {
- if (lista[i].equals(nome)) {
- System.out.println(i);
- _lista.add(i);
- }
- }
- if (_lista.isEmpty()) {
- return -1;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement