Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. package com.gmail.volodimir.bazhan;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. int[] array = { 13, 4, 54, 33, 22, 65, 7 };
  8. int element = 32;
  9. System.out.println(findElement(array, element));
  10. }
  11.  
  12. static int findElement(int[] array, int element) {
  13. int a = -1;
  14. for (int i = 0; i < array.length; i++) {
  15. if (element == array[i]) {
  16. a = i;
  17.  
  18. }
  19. }
  20. return a;
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement