Hi, I want to send 1K bytes string data through the socket. Just wondering, for a string as "abc", is its size 6 bytes? I know one char is 16 bits but I would like to confirm it. Thanks Chris
Jyothi Lature
Ranch Hand
Joined: Oct 31, 2001
Posts: 60
posted
0
Hi Chris, You are right. In java, charis 2 bytes size. So String "abc" is of size 6bytes. Have fun, Jyothi
Jyothi<br />Sun Certified Java Programmer<br />Brainbench Certified for Javascript
Chris Ben
Ranch Hand
Joined: Jan 15, 2001
Posts: 135
posted
0
Thanks. May I ask what exactly is happening if I send a string as "123" or ")|("? I think they are 6 bytes, too, but they are not chars, aren't they? Chris
Jyothi Lature
Ranch Hand
Joined: Oct 31, 2001
Posts: 60
posted
0
Hi Chris, In java, String str = "abc"; is equivalent to: char data[] = {'a', 'b', 'c'}; So, the size of this string variable will be 6 bytes. Similarly, String "123" or ")|(" is again an array of chars whose size will be 6 bytes. Hope its clear. Happy coding. -Jyothi
Chris Ben
Ranch Hand
Joined: Jan 15, 2001
Posts: 135
posted
0
I think I was dumb . thanks a have a good weekend Chris