Home Answers Viewqa Java-Beginners Printing 2 arrays

 
 


Rafal
Printing 2 arrays
3 Answer(s)      11 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

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 Pages:
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
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
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 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
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
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
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
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
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
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 arrays
. Add a new student record 2. Delete a student record 3. Display a student record
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
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
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
PHP Arrays
be easily accessed. There are three kinds of arrays in PHP: Numeric array... containing one or more arrays 3.7.1. Numeric Arrays A numeric array stores...;Bajaj”, “Birla”); 2. In the following example we assign
Arrays
arrays Java 2 added anonymous arrays, which allow you to create a new array... Java NotesArrays Java arrays are similar to ideas in mathematics An array...++, which had a good reason for using zero (pointer arithmetic on arrays
Variable length arrays?
Variable length arrays?  Hi: I enjoy reading from your site...", "jasmine", "lily"}; itemList[1] = {"lotus"}; itemList[2] = {"apple", "orange... of arrays or if there is a smart way to handle this. Thanks for your help. Varma
Arrays - Java Interview Questions
Arrays  1)write a program that take integer array as input and find the second largest number in array?(Array values taken from keyboard)? 2)Given... a program that take arrays A & B as input and find missing element in B array
Introduction to java arrays
Introduction to java arrays   ... of Arrays in Java Programming language. You will learn how the Array class... arrays. To meet this feature java has provided an Array class which abstracts
java 2d arrays
java 2d arrays  Create a program that will: a) Create the array and populate it with the given values. 9, 8 2, 17 49, 4 13, 119 2, 19 11, 47.... and if i do it manualy it is wrong. public class Arrays { public static void main
Arrays -- Examples
Java NotesArrays -- Examples This applet shows a number of methods that use arrays. The source code for the methods is also given below. This applet... = m.length/2; // subscript of middle element if (m.length%2 == 1
arrays - Java Interview Questions
arrays  1)write a program that take integer array as input and find the second largest number in array?(Array values taken from keyboard)? 2)Given... a program that take arrays A & B as input and find missing element in B array
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
Printing the integers before and after - JSP-Servlet
Printing the integers before and after  Hi, I'm trying to print out the integers before and after generated random number, and also stating...} <c:if test="${luckyN}%2==0">It is an even number and it is between
Printing numbers in pyramid format - Java Beginners
Printing numbers in pyramid format  Q) Can you please tel me the code to print the numbers in the following format: 1 2 3 4 5 6 7 8 9 10   Hi Friend, Try
Arrays - Java Beginners
an application that generates a number square like the one below. 1 2 3 4 1 1 2 3 4 2 2 4 6 8 3 3 6 9 12 4 4 8 12 16 Your number square should have the numbers 1...}}; System.out.println("Your Original Matrix: "); for(int i = 0; i < 2; i
arrays - Java Interview Questions
arrays  will un store objects in arrays  Hi friend, Yes u will store Objects in array. Integer[] IntegerArray = { new Integer(1), new Integer(2), new Integer(3
arrays - Java Beginners
and Alist, respectively. another problem.,, 2.)Suppose list is an array of five... executes? for (i = 0; i < 5; i++) { list[i] = 2 * i + 5; if (i % 2 == 0) list[i] = list[i] - 3; } THANK YOU GUYS FOR SHARING YOUR
arrays - Java Beginners
arrays   1. Create a new class (in the employees package) called Dependent, with String properties for first and last names, and property called dependentOf, whose type is Employee 2. It should have a constructor
Converting java arrays into list
Arrays can be converted by the asList() method of the Arrays class...);         System.out.println(list.size());         System.out.println(list.get(2...("------------------\n"+list1.size());         System.out.println(list1.get(2
Probblems with printing if my innput of text file is correct..
Probblems with printing if my innput of text file is correct..  I am trying to make sure this block of code does what I think it will do. Can someone... = Integer.parseInt(line.split(" ")[2
Printing data into Excel sheet - Java Beginners
Printing data into Excel sheet  Hi all i am writing one application..."); rowhead.createCell((short) 2).setCellValue("Last Name"); rowhead.createCell((short) 3...); row.createCell((short) 1).setCellValue(rs.getString(2)); row.createCell((short) 2
Arrays -- Multi-dimensional
Java NotesArrays -- Multi-dimensional All arrays in Java are really linear, one-dimensional arrays. However, you can easily build multi-dimensional arrays... this. These examples all use two-dimensional arrays, but the same syntax and coding can
Two-dimensional arrays
Two-Dimensional Arrays       Two-dimensional arrays are defined as "an array of arrays"... of arrays of  ints". Such an array is said to be a two-dimensional array. 
Introduction to Java Arrays
Introduction to Java Arrays       In this section you will be introduced to the concept of Arrays... in the contiguous memory allocations we use the data structures like arrays. To meet
Introduction to java arrays
Introduction to java arrays       In this section you will be introduced to the concept of Arrays... in the contiguous memory allocations we use the data structures like arrays. To meet

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.