fork download
  1. import java.util.*;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner stdin = new Scanner(System.in);
  8. int n = stdin.nextInt();
  9. ArrayList<Integer> arr = new ArrayList<Integer>();
  10. int[] arr2 = new int[n];
  11. int even = 0;
  12. int odd = 0;
  13. int lasteven = 0;
  14. int lastodd = 0;
  15.  
  16. for (int i=1; i<=n; i++) {
  17. int a = stdin.nextInt();
  18. arr.add(a);
  19. arr2[i] = a;
  20. if (arr2[i] % 2 == 0) {
  21. lasteven = arr2[i];
  22. even++;
  23. } else {
  24. lastodd = arr2[i];
  25. odd++;
  26. }
  27. }
  28. String one = lasteven.toString();
  29. String two = lastodd.toString();
  30. int f = arr.IndexOf(one);
  31. int z = arr.IndexOf(two);
  32. Collections.sort(arr);
  33. if (odd > even) {
  34. System.out.println(f);
  35. } else {
  36. System.out.println(z);
  37. }
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0.16s 321344KB
stdin
5
2 4 7 8 10
compilation info
Main.java:28: error: int cannot be dereferenced
		String one = lasteven.toString();
		                     ^
Main.java:29: error: int cannot be dereferenced
		String two = lastodd.toString();
		                    ^
Main.java:30: error: cannot find symbol
		int f = arr.IndexOf(one);
		           ^
  symbol:   method IndexOf(String)
  location: variable arr of type ArrayList<Integer>
Main.java:31: error: cannot find symbol
		int z = arr.IndexOf(two);
		           ^
  symbol:   method IndexOf(String)
  location: variable arr of type ArrayList<Integer>
4 errors
stdout
Standard output is empty