Please help me I'm a beginner
Code :
public class Ass {
int [] array ;
public static void swap(int [] x) {
for (int i = 0 ; i<x.length ; i++){
int b =0 ;
for (int j = 0 ; j<x.length ; j++){
if ( x[i] > x[j] ) {
b ++ ;
}
}
if (b!=0) {
int temp = x[i] ;
x[i] = x[b] ;
x[b] = temp ;
}
}
}
public static void main (String [] args) {
array = new int [] {1,4,5,7,3,0,8} ;
Ass.swap(array) ;
for (int i = 0 ; i<array.length ; i++) ;
System.out.println(array[i]) ;
}
}
Re: Please help me I'm a beginner
Hi alloka, welcome to the forums!
I've edited your post to add "code" tags. They are described in this faq and detailed in the documentation it links to. The bottom line is that you put [code] at the start of any code and [/code] at the end. That way code will appear formatted and be more readable. (It is also a good idea to check that you have set the code out nicely, with correct indentation and the braces lining up.)
So, what is the problem with that code? Does it compile?
If it does not compile, and you can't understand the compiler's messages, post those messages and say which lines of code they are referring to.
If the code does compile but does not do what you expect or intend at runtime, describe what the code does do and say what you wanted it to do. If there are runtime exceptions, copy and post them.
Re: Please help me I'm a beginner
You should really provide information like what is wrong and what you are having problems with. We can't read minds :s
Re: Please help me I'm a beginner
In an answer of the same quality as the question.
;