Thursday, November 27, 2008

silly string problem!

Today is no different in office. We are nearing the release and test team is chucking out bugs tirelessly. Every day we have more bugs to fix :( As usual i started to work on with a high severity bug. I found the cause without any problem.

But then came a surprise to me. We have a function which takes an array and returns the index of any object you are looking for. So we have an array with few entries and search for an string which is there in the array. But the returned -1 (not found).

I am surprised and puzzled. One things i did was to replace the == with equals method and it worked well. But what I am not clear is why == didn't work. Since string is immutable any string object which has same data will be interned to the same reference in the string pool.

Then I searched on google and found that if any one of the string is read from file, then it is not interned.

consider the following code:
public class Test {

/**
* @param args
*/
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader("c:\\test.txt"));

String str = reader.readLine();
str = str.trim();
String str2 = "A";
System.out.println(str==str2);

reader.close();
}

public final static int indexOf(T[] array, T t) {
for(int i = 0;i
if(array[i]==(t)) {
return i;
}
}
return -1;
}

}

content of the file is just "A", what do you expect the program to print? true? you are wrong.. answer is false. This is where we have to use the intern function in the string class.

Hope somebody will find it useful!!

Monday, November 17, 2008

Wonders with Wii Remote

After iPhone's multi-touch screen and Microsoft's surface, touch-interaction with computer has taken a new avatar. Every other day new video about these technology popup on youtube.

Take a look at the second light multi-touch screen

And today i stumpled upon a TED video about using Wii to create interactive screen. I am particularly excited about the idea of using infra-red to find you visual line of sight. EA is planning to use it in its game.. excited ah!! Take a look!!

Monday, November 03, 2008

The "SHIT" effect

Last Saturday I wrote my TOEFL. To me English was a night-mare in school days (still to some extent). Some how i managed to improve my stance at English little bit, but far from being perfect still.. I crossed GRE successfully, where luck played an important role and people said TOEFL is just a piece of cake (in fact it is), but i am obsessed with the speaking exercise. But i was confident to do it (after 2 years of being YASE, I have taken few presentation in front of 5 to 10 people).

Finally the day came. Reading and listening was a breeze. And then came the toughest part (at least for me), speaking. Trying to calm myself and after adjusting my head phone couple of time, the screen read.

"Describe the city you live in"

So i explained about Bangalore and it did go pretty well.. Ok, I am going to cross this, I said to myself. Then came the actual test. I read the question and mentally prepared my answer. Figuring out the first few sentences I am going to speak (sometimes I still have to form the sentence in Tamil and translate it!). I have 15 seconds to prepare and 45 seconds to speak about the question. After 15 seconds, I started with my answer. I started with few trembling words and gained stability in few seconds. Ah.. I am speaking alright i said to myself.

And then came the most embarrassing moment to me.. Before I could conclud my speaking, I ran out of time,. Two seconds before the clock ceases, it will show you a pop-up saying "Stop Speaking". I too got this pop-up at the end. I don't know what I did, still I couldn't believe it. Out of reflex, unknowingly without my knowledge I said "SHIT" into the microphone and it got recorded!!! What it did I just say? Oh my god, I am screwed. I got tensed. Not knowing what to do. I looked around to see if somebody is there near by, so that I can explain what happened. Nobody is there. I felt too bad, at the same time I wanted to roll-down and laugh for what I did!! then came the next speaking exercise, which I some how managed.. And the remaining exercise didn't go that well !! Any how we can't change the past, atleast I hope they wont ban me from future test :) At least if i would have said "The Magic Four Letter Word", they would have thought I am an American!!! LOL!!!

I know this is not fun, but unfortunately people enjoyed it.. So I am putting it in my blog :) After all life is about FUN!!

Cheer and Keep laughing,
BY "THE ONE WHO SAID 'SHIT' IN TOEFL"