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");
Ads
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
Advertisements
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 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
2d arrays
2d arrays what is the code for multiplying the values in a 2d array and
printing out their sum
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
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