fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public void printArray(int[] arr){
  11. int n=arr.length;
  12. for(int i=0;i<n;i++){
  13. System.out.println(arr[i]+" ");
  14. }
  15. // System.out.println();
  16. }
  17. public void array(){
  18. int[] myArray=new int[5];
  19. myArray[0]=1;
  20. myArray[1]=9;
  21. myArray[2]=8;
  22. myArray[4]=8;
  23. myArray[3]=7;
  24. myArray[0]=7;
  25. printArray(myArray);
  26. System.out.println(myArray.length);
  27. System.out.println(myArray[myArray.length-1]);
  28. int[] arr={5,1,8,10};
  29. printArray(arr);
  30. }
  31. public static void main (String[] args) throws java.lang.Exception
  32. {
  33. // your code goes here
  34. Ideone a=new Ideone();
  35. a.array();
  36.  
  37. }
  38. }
Success #stdin #stdout 0.1s 48136KB
stdin
Standard input is empty
stdout
7 
9 
8 
7 
8 
5
8
5 
1 
8 
10