I noticed that someone else posted a answer that looks just about right
... But I have a couple of pointers for you.
First of all you change bracketing inside your class file i.e. you start
off with ...
> public class Tester{
>
> public static void main(String[] args){
Bracketing that comes after your method decleration and then you ...
> for (int i=1; i<v.length;i++)
>
> {
Change to putting the bracket underneath the begining of the method
decleration.
Now both methods are good, just not in the same class file. It makes it
easier to get confused about what brackets are where.
>
> if (v[j+1]>v[j])
>
> temp=v[j+1];
This is a perfect example of why you should never realy put a if
statement on a second line unless it is in {} blocks. I mean technicaly
there isn't a problem with it, but it is so easy to put a new line in,
or make a space (like you did) and it just breaks everything.
I now force myself to either write it all on one line
if (someStuff) doStuff();
If for some reason I can't I put it in a {} block
if (someStuff){
doStuff();
}
It might add lines to your code, but it always places bets on the safe
side of coding. While not doing it can harm readablity and can make it
dangerous.
It isn't the worst habit you can do, and realy you can make you own
decision on if you want to do it or not.
It is my experiance however that it constantly bites you on the bum.