Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Printing 2 arrays

Have Programming Question? Ask it here!
 
 
 


Rafal
Printing 2 arrays
3 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners


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


Advertisement
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
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 -- Intermediate
Java NotesArrays -- Intermediate Anonymous arrays Java 2 added anonymous arrays, which allow you to create a new array of values anywhere... arrays in a loop or as local variables because each use of new will create
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
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: ibrahimbest@gmail.com
Arrays in java
Arrays in java  what is param array in java
printing java series
printing java series  * *** ***** ******** ***** *** *   Post the format properly
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
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
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
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 { /** * @param args the command line
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
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
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
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
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
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
Printing ArrayList - JSP-Servlet
Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total); RequestDispatcher rd; rd = request.getRequestDispatcher("/checkout.jsp"); rd.forward
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
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
create arrays in JavaScript
create arrays in JavaScript  How to create arrays in JavaScript
java arrays
. Add a new student record 2. Delete a student record 3. Display a student record
Printing Session Id Using Variable
Printing Session Id Using Variable  Hi, I am a learner in PHP language. Could any one guide me, how to print session Id using variable in PHP. Thanks
arrays in java - Java Beginners
arrays in java  Hi All, I have two arrays. in this two array some name are same. I want to merge those arrays into single. But while merging I want to delete duplicate entries. How merge those arrays. Thanks, mln15584
Advertisements
 

 

 

DMCA.com