Printing 2 arrays

Printing 2 arrays

Hi, I have 2 arrays:

String [] head = {"Name", "Date of birth", "PPS number"};
String [] personal= {value1, value2, value3};

I want this 2 arrays to be printed out in the following manner:

head[0] tab personal[0]
head[1] tab personal[1]
head[2] tab personal [2]

I tried different options and can't get this working properly. Any suggestions? Many thanks in advance!

Rafal

View Answers

May 28, 2012 at 10:14 PM

Try this code:

for(int i=0; i


May 28, 2012 at 10:19 PM

for(int i=0; i<person.length; i++)
        {
          System.out.println(head [i]+"\t"+personal [i]);
        }

May 29, 2012 at 1:42 AM

HI!

Thanks for your reply.

Your solution did not work since I'm using GUI (JFrame) but below workaround worked for me:

fieldTaxReceipt.setText(personalHead[0] + "\t" +

personal[0] + "\n" + personalHead[1] + "\t" + personal[1] + "\n" + personalHead[2] + "\t" + personal[2] + "\n");









Related Tutorials/Questions & Answers:
Printing 2 arrays
Printing 2 arrays  Hi, I have 2 arrays: String [] head = {"Name... want this 2 arrays to be printed out in the following manner: head[0] tab personal[0] head[1] tab personal[1] head[2] tab personal [2] I tried different
arrays part 2 - Java Beginners
arrays part 2  Question 2: Useful Array Algorithms and Operations (5 marks) Upgrade the program in Question 1 so that the program includes: ? A static method search() that: o Has a parameter of integer array and another
Advertisements
how to compare 2 arrays using java?
how to compare 2 arrays using java?  hi can anyone give me the information regarding comparision of arrays.   Java Compare Arrays
Arrays
Arrays   Hi I need help with the following exercises. Exercise 1: Write a Java application in which the user is prompted for the total number... of all the values as well. Exercise 2: Write a Java application in which you
Arrays
called Rebel.java; 2.Create two arrays. One of them must store integer numbers... the numbers in the second array by 3; 7.Print out the contents of both arrays. 8.Swap...); } numbers[0] = 6; words[0] = "1"; numbers[2] = 8; words[2] = "3
arrays
arrays  using arrays in methods   Java use arrays in methods import java.util.*; class ArrayExample{ public static int getMaxValue(int[] arr){ int maxValue = arr[0]; for(int i=1;i < arr.length;i
arrays
Store a table with students and information (name, ID, password, crypted password, etc) in a multi-dimensional array "stud"  Arrays and Strings: Store a table with students and information (name, ID, password, crypted password
Arrays
Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island  Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island
arrays
tempArray1And2[] = new int[(tempArray1.length+ tempArray1.length)-2
printing in swing
printing in swing  How can i print payslip in swing
Printing stars
Printing stars  I am a beginer and i have one assignment which couldnt give me any idea how to do it..The Question is "Get a string "001222014654" and print o/p as 0 - * 1- ** 2- * 4- ** 5-* 6-* I dont know how to split
applet printing
applets gridwise and in each applet i am drawing some graph so while printing whole... but while printing it is not getting printed on paper and rest everything it is printing
printing in java
printing in java  hello i want to print a jInternalframe containing some lebels,but my printer sent me a paper with the following written on it: please what is the problem
Arrays in java
Arrays in java  what is param array in java
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: [email protected]
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
ModuleNotFoundError: No module named 'Printing'
ModuleNotFoundError: No module named 'Printing'  Hi, My Python... 'Printing' How to remove the ModuleNotFoundError: No module named 'Printing... to install padas library. You can install Printing python with following
printing java series
printing java series  * *** ***** ******** ***** *** *   Post the format properly
java arrays
java arrays  can i know how can we intilize the three dimentional arrays in java? and how can we assign thae values to that array
java arrays
java arrays  i need a java program to store student details like id,name,addr,marks,average,total..using arrays..input data using scanner class and by using class, object and constructor
Converting java arrays into list
into a variable and use in your program. In this program we are just printing the size of the list. Arrays can be converted by the asList() method of the Arrays class. asList() It converts the object array into the fixed sized
java arrays
java arrays  how do you write the code for multipliying 2 double arrays to be in a 3rd double array? here is my code: package employeepay; /** * * @author Owner */ public class Main {ADS_TO_REPLACE_1 /** * @param args
Java with Arrays
Java with Arrays  I was given the assignment to create two parallel arrays; both of size 50 (declares 50 as a constant) One is an array of strings... and store it in the arrays. The input for the problem should be provided in a text
arrays
Arrays
Arrays
arrays
arrays
arrays
arrays
arrays
Arrays
arrays
arrays
printing series in java
printing series in java  1 123 12345 1234567 12345 123 1...){ for(int i=1;i<=7;i+=2){ for(int j=1;j<=i;j...(); } for(int i=5;i>=1;i-=2){ for(int j=1;j<i+1;j
create arrays in JavaScript
create arrays in JavaScript  How to create arrays in JavaScript
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
Compare two Byte Arrays?
Compare two Byte Arrays?  Compare two Byte Arrays
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
Printing server information
Printing server information  Hello, I am learning PHP language. I trying to fetch the server Information Print. How could i will printing the server... connected to your PC? This it best example for the Printing server Information
printing example - Java Beginners
printing example  Is it possible to print java controls using print method? My problem is to print a student mark list using java? The mark list should like that of university mark list
Java Printing - Java Beginners
Java Printing  Can anybody plz help in giving the code for printing the contents of JPanel.. It contains JLabels and JTextFields only.. Plz.. Its urgetn.. Printing means sending the document to the Printer..  Hi Friend
how printing landscape?
how printing landscape?  I have code which print some data from data base with "drawString()" and it works correct when I chose "Portrait" from "Print Dialog", but it does not work if chose "Landscape". Is any way to print
printing hollow square
printing hollow square  Write an application (PrintingSquares.java) that prompts the user to enter the size of the side of a square, then displays a hollow square of that size made of asterisks. Your program should work
patterns printing using for loop in java
patterns printing using for loop in java  how to write the code for the pattern as: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Printing numbers up to N into a file
Printing numbers up to N into a file  I'd like to print the first N integers, that is, "1, 2, 3, 4, ..., N-1, N", say N equals 1000, or 10000 or whatever. I'd also like to have the result stored as a file instead of having
Java Arrays
[] counts ={3,2,1,0}; int len = 2; reduce(counts,len); for(int k: counts
java arrays
. Add a new student record 2. Delete a student record 3. Display a student record

Ads