• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
akash negi
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.valueOf()
 
akash negi
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind.. I figured that out.. the else if statement was not neccessary..


Thanks..
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic