hi friends,
last night i was doing a programmes from one ebook,i look at one
programme that look very easy at first look and i created but then i
realize its bit of diffrent than i thought, here is the program.
"Write a Program that takes any no. of strings as command line argument
and print that string and its length in characters."
at first i created the program which outputs that string and its
length,but only problem was it prints length in no.whereas program
requires output in characters.i have search allmost every java book
that i have but i was unable to find any mathod or anything like this
so friends if anyone knows any technique or mathod then please reply
me.
Ingo R. Homann - 19 Apr 2006 10:42 GMT
Hi,
> hi friends,
>
[quoted text clipped - 11 lines]
> so friends if anyone knows any technique or mathod then please reply
> me.
Do you mean the diffenece between String.length and
String.getBytes().length or what do you mean?
Perhaps you can post your code...
Ciao,
Ingo
Chris Uppal - 19 Apr 2006 10:53 GMT
> "Write a Program that takes any no. of strings as command line argument
> and print that string and its length in characters."
>
> at first i created the program which outputs that string and its
> length,but only problem was it prints length in no.whereas program
> requires output in characters.
I think the book means
print that string, and the length (in characters) of the string.
I.e. it's telling you what it means by "length" (the number of characters)
rather than telling you that you have to print out the result in a strange way.
So you've already solved the problem :-)
Of course, if you want to solve the other problem /anyway/
cat three
elephant eight
then that's more difficult, and -- as you've found -- there is no standard
method. It's probably a bit beyond you so far, but if you want to try it then
you'll need to use arrays of fixed strings (don't worry if you don't know what
that means yet).
-- chris
Roedy Green - 20 Apr 2006 01:36 GMT
>at first i created the program which outputs that string and its
>length,but only problem was it prints length in no.whereas program
>requires output in characters.i have search allmost every java book
>that i have but i was unable to find any mathod or anything like this
>so friends if anyone knows any technique or mathod then please reply
>me.
That sounds like something King Of the Hill's Boomhauer might say. Try
posting your code. It will explain your problem more eloquently.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.