package test;
import java.util.ArrayList;
import java.util.List;
public class testing {
public static void main(String[] args) {
List<Integer> l= new ArrayList<Integer>();
l.add(1);
l.add(7);
l.add(90);
l.add(67);
int temp;
for (int i = 0; i < l.size(); i++) {
for (int j =0 ; j < l.size(); j++) {
if(l.get(i)>l.get(j)){
temp = l.get(i);
l.set(i,l.get(j));
l.set(j,temp) ;
}
}
}
for (int i = 0; i < l.size(); i++) {
System.out.println(l.get(i));
}
}
}
See :
How to reverse a string in java
Difference between Arrays.sort() and collections.sort()
How to add instance of a class to list and then reterieve it
Constructor,Constructor Interview Questions
Overriding/method Overriding In java
import java.util.ArrayList;
import java.util.List;
public class testing {
public static void main(String[] args) {
List<Integer> l= new ArrayList<Integer>();
l.add(1);
l.add(7);
l.add(90);
l.add(67);
int temp;
for (int i = 0; i < l.size(); i++) {
for (int j =0 ; j < l.size(); j++) {
if(l.get(i)>l.get(j)){
temp = l.get(i);
l.set(i,l.get(j));
l.set(j,temp) ;
}
}
}
for (int i = 0; i < l.size(); i++) {
System.out.println(l.get(i));
}
}
}
See :
How to reverse a string in java
Difference between Arrays.sort() and collections.sort()
How to add instance of a class to list and then reterieve it
Constructor,Constructor Interview Questions
Overriding/method Overriding In java
No comments:
Post a Comment