Sunday, May 2, 2010

Sorting a list in java using comparator

[sourcecode language="css"]
public class SortTest {
    public static void main(String[] args) {
        List<Integer> ls = new ArrayList<Integer>();
        for (int i = 1; i &lt; 10; i++) {
            Random r = new Random();
            int randomNo = r.nextInt(i);
            ls.add(randomNo);
        }
        System.out.println("before sorting:" + ls);
        Comparator c = new Comparator() {
            @Override
            public int compare(Object arg0, Object arg1) {
                if ((Integer) arg0 &gt; (Integer) arg1) {
                    return 1;
                } else if ((Integer) arg0 == (Integer) arg1) {
                    return 0;
                } else {
                    return -1;
                }
            }
        };
        Collections.sort(ls, c);
        System.out.println("after sorting:" + ls);

    }
}
[/sourcecode]

Sunday, May 24, 2009

5 quotes that will force you to rethink, if u think u are a failure.

Hi, today i m posting some quotes spelled by some great peoples in this earth. 1. I have not failed. I've just found 10000 ways that wont work.Thomas A Edison. 2. I have missed more than 9000 shots in my career. I have lost almost 300 games. 26 times I have been trusted to take the the game winning shot and missed.I have failed over and over and over again in my life. Thats why i succeed. Michael Jordon. 3. If you think you are beaten, then you are. if you u think you can't succeed then really you can not. Because Life's battles dont always go. but sonner or later only who wins WHO THINK HE CAN. Anonymous 4. If u want to succeed, then double the rate of failures. Dhirubhai Ambani Last but not least : Dreams are not those are seen during sleeping .Dreams are those let you not sleep.

Tuesday, May 19, 2009

my views

Sometimes i think, how life is much boring. Sometimes i started thinking i have bad luck. These all diffculties are with me. but then i realiase, No its not bad to that level that i am thining. I see the peoples like laboures etc i feel i m much better than these guys. Then i got a gratitude about these things to god; Yes i am really lucky.