Two Laptop Bag*
The moose likes Java in General and the fly likes converting int to String using toString()  ?? possible?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting int to String using toString()  ?? possible??" Watch "converting int to String using toString()  ?? possible??" New topic
Author

converting int to String using toString() ?? possible??

akash negi
Greenhorn

Joined: Feb 24, 2010
Posts: 27
Hi all, I am trying to write this program to compress a sequence using RLE compression.


for example--
wwwerrrrrttttttttttt will be 3we5r11t



However, in the code I am getting an error

toString() in java.lang.Object cannot be applied to (int)



I am using toString() because of this..toString()







comp = comp + toString(counter) + uncomp.charAt(pos);
counter = 1;
}
}


comp = comp + toString(counter) + uncomp.charAt(pos);
counter = 1;



basically I am trying to convert an int value to String. So that it can be concatenated to another string.


Please help..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

String.valueOf()


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
akash negi
Greenhorn

Joined: Feb 24, 2010
Posts: 27
thanks for that

however, not the program has logical errors.

for:

eeeer - e4r; which should be 4er
tttyyyuuui - tyu7i; which is completely off..

any help on correcting that..

I wrote 3 other progs. altogether and am a little confused.

Thanks.
akash negi
Greenhorn

Joined: Feb 24, 2010
Posts: 27
Never mind.. I figured that out.. the else if statement was not neccessary..


Thanks..
 
Consider Paul's rocket mass heater.
 
subject: converting int to String using toString() ?? possible??
 
Similar Threads
need help with compareTo()
Equals Method problem
[Easy] Shift String
Parsing words
Knuth Morris Pratt Search Algorithm Help