Results 1 to 8 of 8
Thread: [SOLVED] String Length issue.
- 01-08-2009, 08:39 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 32
- Rep Power
- 0
[SOLVED] String Length issue.
Hello
I have yet another question which will be very basic to you guys. :D
I have tried searching the forums and google for the answer but i really can't find it.
I'll give you an example of what i want to do.
In between the two +'s with the \t i want to add the length of the string in as extra space so the columns line up properly when displayed.Java Code:String Name = "Chris"; int NameLen = Name.length; System.out.println(Name + "\t" + Channel);
On VB i remember it used to be len(VALUE) but i have no idea in java and can't find it. lol
Thanks
--
Chris
- 01-08-2009, 08:43 PM #2
Member
- Join Date
- Dec 2008
- Location
- Italy
- Posts
- 79
- Rep Power
- 0
See the documentation for printf()
Formatting out
- 01-09-2009, 07:32 PM #3
System.out.println(name + "\t" + name.length() + "\t" + channel);
Don't capitalize the first letter of field names: thisIsAFieldName
- 01-09-2009, 08:29 PM #4
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
- 01-10-2009, 12:20 AM #5
Raffaele and Neil both gave good suggestions. If you take some time, Java can do a great deal of formatting with a small amount of weird-looking code (comes from the C background) ;-)
- 01-10-2009, 01:59 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 01-10-2009, 08:35 PM #7
Member
- Join Date
- Jan 2009
- Posts
- 32
- Rep Power
- 0
Thanks guys, i will have a look at doing this once i have done the bigger jobs. Leave the little ones to last.. hehe
- 01-11-2009, 03:16 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Well design project is really easy to implement. Doesn't matter how challenging a single step there. :)
Similar Threads
-
what does num.length method does?
By kris09 in forum New To JavaReplies: 1Last Post: 08-07-2008, 10:19 PM -
queue length of Socket
By hemant in forum NetworkingReplies: 6Last Post: 07-13-2008, 06:28 PM -
Integer length
By jithan in forum New To JavaReplies: 1Last Post: 06-12-2008, 03:35 PM -
Finding the exact length of a string in a JLabel (in pixels)
By Clarkey in forum Advanced JavaReplies: 2Last Post: 03-25-2008, 05:49 AM -
Help with method length
By toby in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks