Any suggestions on making toString printouts nicely?
im trying to print out info from an array by doing
for(int i = 0; i < array.length; i++)
System.out.println(array)
but everytime the array[5] gets printed out its like this:
Name Age Birthday
John Doe 18 0/00/00
John 18 0/00/00
....the way im printing it out is by creating a table with /t that i did already in my toString method from the class with getName(), getAge() and such. so its evenly spaced but whenever the name being printed out is short the spacing or /t moves up causing it not to be aligned. any suggestions on how to fix it or if you had this problem also are there any other ways to print it out and have it aligned like a table.?
You should be able to adapt this
public class PrintInColumns {
public static void main(String[] args) {
/* Prints to DOS/cmd window in columnar format using
System.out.println. If you don't need 5 columns, just
set the unused dataN values to the null string "".
stBuf StringBuffer is initialized to 75 spaces.
This can be changed if desired.
// Change ColN to your desired start column
final int Col1 = 0; // data1 start column
final int Col2 = 15; // data2 start column
final int Col3 = 30; // data3 start column
final int Col4 = 45; // data4 start column
final int Col5 = 60; // data5 start column
String s = " ";
StringBuffer stBuf = new StringBuffer(s);
// To print multiple lines, create a loop that encloses the
// code below this point.
// Convert all variables to strings and place them in the
// following lines
String data1="Hotshot";
String data2="Programmer";
String data3="(800)555-1212";
String data4="Big Co., Inc.";
String data5="";
stBuf = ((((stBuf.replace(Col1, data1.length() + 1, data1)).
replace(Col2, Col2 + data2.length() + 1, data2)).
replace(Col3, Col3 + data3.length() + 1, data3)).
replace(Col4, Col4 + data4.length() + 1, data4)).
replace(Col5, Col5 + data5.length() + 1, data5);
System.out.println(stBuf);
}
Similar Messages
-
Any suggestions for making a treasure map for kids party on IMac?
I need to make a pirate type treasure map. Any suggestions?
You can even do it without a Mac :-(
http://www.wikihow.com/Make-a-Pirates-Treasure-Map-for-Children -
It is most sluggish when I turn on my laptop after it has been shut down overnight or for any other period of time.
-> Update Firefox to the latest version 10.0.1
* [[Installing Firefox on Mac]]
-> [[Firefox hangs]]
Check and tell if its working. -
Any suggestions on making the documents 'PDFd' from Outlook smaller?
I am using Outlook 2013, and Adobe Acrobat XI Standard.
When I click on a message, and then right click and select "Convert to Adobe PDF", it creates a document that is roughly 500KB.
Comparatively, if I save the email message to a file, it is about 50KB.
If I print the message, to and Adobe PDF document, it comes in at about 160KB.
I see that the aim of these commands appears to be for archiving purposes, to move your emails into a format or location that can better manage records. However, having a 10x increase in the space makes it very unappealing.
Is there a way to adjust these settings, to make the files smaller perhaps?
What options are there, that perhaps I am not aware of?
ThanksHi Bill Tkach,
Thank You for posting on the forums.There are few things that Acrobat does while the e-mail is being converted to PDF depending on the settings chosen.
1) Embeds index for faster search
2)Creates a portfolio of the message
3) Adds security to the file
Follow the steps mentioned below and check if it helps.
1) select the message you want to convert to PDF
2) Click on the Acrobat botton
3)Click on change conversion settings
4) Uncheck the options that are not useful to you
5) proceed with the conversion.
Thanks,
Vikrantt Singh -
To move the iTunes library to this new computer I switched on Home Sharing and can see the other libraries on my home network. If I select tracks from a Shared library I can't import them as the strip containing "Show: All Items" and the "Settings" and "Import" buttons, does not display at the bottom of the screen. Goes straight from the list of tracks to the strip with Playlist icons and xxxx items, tttttt total time, yyyy GB.
Any suggestions for making the Import button appear?I hvae the EXACT same issue
I built a new computer which is EXTREMELY fast overclocked i7 ect and.. ITUNES DOESNT WORK
I click on itunes which ive uninstalled and reinstalled and reset the winsock AND seen if there were any errors AAAAAAND ive check the Hkey to make sure bonjur was the only one in there which it is and all that happens is my cpu goes to 25% and i cant do anything except go into the task manager and close it! ANYTHING with itunes (everything else is premium speed).
what do i do
windows 7 64 bit -
Any suggestions for making this work with Mountain Lion? I've tried all similar solutions on web. I've been able to get this to work with Lion, and after upgrading to Mountain Lion it seems to hold true (doesn't make me implement again). But when I went from OSX 10.6 to Mountain Lion and have to implement it on 10.8 - it isn't working. Thanks.
Any suggestions for making this work with Mountain Lion? I've tried all similar solutions on web. I've been able to get this to work with Lion, and after upgrading to Mountain Lion it seems to hold true (doesn't make me implement again). But when I went from OSX 10.6 to Mountain Lion and have to implement it on 10.8 - it isn't working. Thanks.
-
I want to use an external microphone for both my iPhone 5S and my MacBook Pro. This is for music and for making recordings outside such as birds. Any suggestions?
use a splitter something like this
http://www.amazon.co.uk/3-5mm-Headphone-Splitter-Cable-iPhone-White/dp/B003W37DS E/ref=pd_sxp_grid_pt_2_1 -
iTunes is telling me that I have not purchased from my iPhone before although I have multiple times, and I don't remember my security questions and there is no option to change them. Any suggestions other than making a new account?
If you create a new Apple ID you won't have access to the media purchased with the Apple ID you are currently using.
Try here > Rescue email address and how to reset Apple ID security questions -
bought a new windows computer and older and newer versions of photoshop have extremely small icons/font/tools...etc., making it almost unusable. Any suggestions? Or, do I take my new computer back?
That's Adobe for you!
No matter how much we request, beg and/or complain, nothing is done about the miserably small interface.
We're still left with the three inadequate choices in preferences:
Other than that, you can change your monitor's resolution. -
Recently my mac has started making faint clicking noises just like a fan catching against something, it is only faint but loud enough to hear. any suggestions please
While it could be a cooling fan, a noise like that is usually a sign of a dying hard drive. Back up everything immediately. Make immediate backups of any new documents you create after the full backup.
-
the charger is showing green but the laptop will not turn on. The stand-by light is flashing and the laptop is making a bleeping sound. Any suggestions?
Could be bad ram or logic board. Take it to an Apple store or AASP.
-
My macbook pro is making strange fan related noises. Sounds as if something is stuck in the fan. First time this has happened since I got my computer. Every time I put it to sleep I wouldn't hear the sound anymore. Any suggestions?
... Sounds as if something is stuck in the fan.
Probably is. They get dusty. Shut down your computer and clean it out with a vacuum (don't blow dust back inside). -
It's a low whirring, I'm sure it's louder than it used to be and it definitely gets louder the more windows I have open, or applications are running, iTunes with Photoshop and Safari etc. causes it to get much louder. It's not the actual fan as far as I can tell, the other day I put it to sleep and it instead froze and the fan was really loud in that case and I just had to turn it off at the back.
I tried repairing the disk permissions, it's made no difference. I can't see anything out of place it Activity Monitor but I might be wrong about that.
Is it a case of the Mac getting too hot, or just that it's nearly 6 years old?!
Any suggestions would be great, thanks.First, make sure that all your air vents are free of dust and lint.
Then,try http://support.apple.com/kb/HT1436 Resetting SMU
After that, if you do not have an iSight, open the back and look for bulging or leaking caps (the little soda can). It's likely that either some caps are bad or your power supply unit is failing. Go to User>Applications>Utilities>Console and type in maximum temperature in the little box at the top right of Console. If you see any heat messages, then your problem is likely what I suggested. -
I am unable to drop my ringtone into my tones folder that I dragged from my desktop. For some reason the tones folder won't take it. Any suggestions??
Instead of dragging, try to "add file". Click on the Music dropbox at the leftcorner under File Edit View bar, choose Tones. Then click on the dropbox at the top left corner and select Add File to Library, from there browse to your ring ton file and add it. :-)
-
after updating software on my iphone 4 to iOS it is unresponsive to touch & I cannot power it off in order to restore to factory settings. does anyone have any suggestions? thanks!! i'm desperate!
Try a reset: hold down the home button along with the power button until you see the Apple, then let go.
Maybe you are looking for
-
How to send smartform output in body of email?
Hi all , I have to send smartform output in body of email (not as an attachement in mail) .PLease help me in this regard. Thanks, Ananth S.
-
How to implement validations in message mapping?
Hi experts, I have a simple requirement: I have a simple synchronous scenario: SOAP -> XI -> RFC In a message mapping, one of the fields in the source message is of type String. However, the target application (RFC) does not expect a non-numeric char
-
How to see status of emails stopped in queue
Hello, I'd like ask you how is possible define reason of non-deliveriyng mail mesage. Below is my analyses: 1. list of all messages in queue (similar aoutput as mailq from *nix like systems) (Machine esa1.DOMAIN.XYZ)> showrecipients all Showing messa
-
Camera raw and elements 4.0 on a mac
I run elements 4 (version 4.0 according to the 'about elements' box) on a power pc mac running Tiger 10.4.9. I've downloaded camera raw 4.1 and installed it as per the adobe instructions into the 'file formats' folder, removing the previous version o
-
I no longer have favicons in address bar (awesome bar)
Firefox 14.0.1 I no longer have favicons in address bar (awesome bar): All that shows is a a generic graphic(globe?) that is grayed out. I do however still have fevicons in my bookmarks list. Thanks for your help!