Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Nelson Sam

Ranch Hand
+ Follow
since Jun 12, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nelson Sam

I am doing this swap program to swap to integers.I want the result to be printed from the main method.i.e. the values after swapping.Is there any way out to print the value of a and b in main method

11 years ago
Thank you all for replying.

@Hunter McMillen-Thanks for pointing out where I went wrong.
@Rene Larsen-Thanks for the concept.I have implemented it in my program
@Rob Prime - Thanks for your idea too.

11 years ago
Thanks Abimaran Kugathasan .I really like your approach.Will try and let you know.

@Hebert Coelho-Thanks for the code.Works really fine.Exactly what I was looking for
11 years ago
I am trying to reverse the string s1 using the below code and store it in char array named c.
But I am getting the same s1 as output instead of it being reversed.

11 years ago
I want to read an input from the user.If the input is anything other than number the exception should be thrown.And should prompt the user to again input until the input is a number.

I have done the code this far.



Appreciate for all your help.
11 years ago
Okay
I have found the solution.
Below is the code

11 years ago
Hi Henry Wong.
I know how to read and write files.Below is code written by me to read a file.I also know the use of arrays and loops but not collections

11 years ago
I want to read a text file that has contents like this


1 2
3 4
5 6
7 8
9 10



I want to read it into two arrays.First array should contain 1,3,5,7,9 and Second array should contain 2,4,6,8,10.

I have no idea how to do this

Any Help will be highly appreciated
11 years ago
Hi Seetharaman Venkatasamy

I know using sort() method.
But I want to sort programatically.
11 years ago
I am trying to sort an array.Below is the code.But I cant get it working properly.

11 years ago
Hi Ernest Friedman-Hill.

I compiled and ran the program again and I showed characters only.

So I just created new java file and copied this contents to this file and compiled,run again I got Output in integers.

Here is a snapshot of same program with different outputs





11 years ago

Rob Prime wrote:Ehm Ulf? This is a primitive. It just prints the int as it is.

Nelson Sam wrote:prints the characters without casting it to character.


Why would it cast to character automatically? Haven't you declared ch to be an int? You should cast to char manually.



I mean that the program is giving correct output even if I dont cast ch to char.

i.e,

System.out.println(ch);
OR
System.out.println((char)ch);

Both give same results
11 years ago
I am trying to read the contents of a file using FileReader.
Here I am using a read() method to read it.The read() reads character and returns integer in range 0 to 65535.

So I have created int ch,but System.out.println(ch); works and prints the characters without casting it to character.I am confused at this point

11 years ago
Thanks for suggestion Peter Taucher.

Here is how I solved the problem.

OLD ONE


NEW ONE


Earlier I had assigned the file name to string f.and checked using exists() method of file class,Since f is a string and doesnt belong to a file class f.exists() didnt work.

So I corrected it to
File f;
f=new File("nel.txt");
Boolean check=f.exists();

11 years ago
Thanks for the interest friends.
My problems are solve now
See you very soon with another one
11 years ago