java - Sorting of an array without using array.sort -
i not getting output of code dont understand error in code can help? using ide , error shows not understandable me .i pasting code below know
class sort_basic { public static void main (string[] args) { int[] myint=new int[]{20,100,69,4}; for(int a=0;a<myint.length;a++) { for(int b=a;b<myint.length;b++) { if(myint[a]>myint[b]) { int temp; temp=myint[a]; myint[a]=myint[b]; myint[b]=temp; } } } system.out.println("sorted array is:"); for(int i=0;i<myint.length;i++) { system.out.println(myint[a]); } } }
for more understanding pasting o/p here: 24: error: cannot find symbol system.out.println(myint[a]); ^ symbol: variable location: class sort_basic 1 error
for(int i=0;i<myint.length;i++) { system.out.println(myint[a]); // ^ wrong variable }
you typed a
instead of i
.
Comments
Post a Comment