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



Home Answers Viewqa Java-Beginners print array in following format
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Abhishek Sharma
print array in following format
1 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners


i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19

i want output as:

1 2 3 11 12 13 4 5 6 14 15 16 7 8 9 17 18 19


Advertisement
View Answers

September 14, 2012 at 4:55 PM


Here is a code that displays the array values in the following pattern:

1 2 3  11 12 13
4 5 6  14 15 16
7 8 9  17 18 19

class DisplayArray 
{
    public static void main(String[] args) 
    {
        int array1[]= {1,2,3,4,5,6,7,8,9};
        int array2[]={11,12,13,14,15,16,17,18,19};

        int rows = 3;
        int columns = 3;
        for (int row = 0; row < rows; row++) {
        for (int column = 0; column < columns; column++) {
            System.out.print(array1[row * columns + column]+" ");
        }
        System.out.print("  ");
         for (int column = 0; column < columns; column++) {
            System.out.print(array2[row * columns + column]+" ");
        }
         System.out.println();
        }
    }
}


Related Tutorials/Questions & Answers:
print array in following format
print array in following format  i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19 i...; Here is a code that displays the array values in the following pattern: 1 2
Print the following format
Print the following format  how to print the following format given string "00401121" in java 0-** 1-* 2-* 3- 4
Advertisements
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334 4322234 4321234 4322234 4333334 4444444 // for input 4. And also
print the following series
print the following series  a b c d e b c d e c d e d e e   Hi Friend, Try the following code: class StringPattern { public static void main(String[] args) { String st="abcde
how to print the following pattern
how to print the following pattern  Hello hEllo heLlo helLo hellO pls reply soon its an emergency   class StringPattern { public static void main(String[] args) { String st="hello
How to print this Format exactly?
How to print this Format exactly?   * * * & reverse
how to print pdf format
how to print pdf format  Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list /attendence in pdf format. please help me. thanks in advance.   Here
How to print the following pattern in java?
How to print the following pattern in java?  How to print the following pattern in java? he he is he is going he is going in   import java.io.*; class StringPattern { public static void main(String[] args
write a program in C to print following triangles on the screen
write a program in C to print following triangles on the screen  write a program in C to print following triangles on the screen
i want print the following out put
i want print the following out put  Hello sir i want the following out put can u provide the program in c# o/p; HELLOLLEH HELLLEH HELEH HEH H
C Program to Print Following Output - Development process
C Program to Print Following Output  Hello Sir I wnat to print Followning output in C Language with for loop How I Can Print it? 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1  Hi Friend, Try the following: #include
How to print the following output using c program
How to print the following output using c program  1) 4 3 4 2 3 4 1 2 3 4 2) A B C D E F G H I J
Simplest way to print an array in Java
Simplest way to print an array in Java  Simplest way to print an array in Java
how to create an xml file in following clear format
how to create an xml file in following clear format  anyone please help me out to create this file,,. <Tasks> <Taskid>1 <Taskname>Coding <Project>CeMIC <Date>
How to Print Array in JavaScript
How to Print Array in JavaScript In this section you will learn about Array in JavaScript. Array are important part of all programming languages. Array...;<h2>Click to print the array element</h2></p><p><input
how to check and print the no of times an integer is repeated in an array
how to check and print the no of times an integer is repeated in an array  how to check and print the no of times an integer is repeated in an array??? suppose my input is 2 4 2 5 2 4 3 4 5 2 then my output should be 2-4
JavaScript array print
JavaScript array print     ... print them wherever we wish. Here is the simple example of array printing which... have used a for loop to print all the elements of the array. for(var i
how i can print the elements before a spicific value in array queue?
how i can print the elements before a spicific value in array queue?  how i can printall elements befor the spicific value and print this value also   Hi Friend, Try this: <html> <script> var arr=new Array
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
print selected checkbox names in array without form tag
print selected checkbox names in array without form tag  Hi everyone ... I have problem in my program. I have hashmap i.e. collection , my code is as follows [code] <%! private HashMap<Integer, Domain>domainmap
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code sample"); package bankprj3; class Account { private double Balance; public Account(double initBalance){ Balance=initBalance; } public
Print
into the stream and, as opposed to print() method, gets you to the new line after the text
I want to know the all possible syntax for EL code to print the first element of an array.
I want to know the all possible syntax for EL code to print the first element of an array.  Which is the correct EL codes syntax to print the first element of an array named employeeArray. ${employeeArray["0"]} or ${employeeArray
Simple Date Format Example
Following is a simple date format example made using Format class. We have uses a pattern of special characters to date and time format. In this example, SimpleDateFormat:class is used to format date into text and parse text into date
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
Sql Date and Time Format
Format'. To understand this example we use the following syntax that  is used to  format date and time.  SYNTAX:- DATE_FORMAT(date,format... Sql Date and Time Format     
how to print the average of each column of 2d n*m array using java
how to print the average of each column of 2d n*m array using java  here is my code: import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public
array
will print only the designated portion of the array. Validate low and high; if either...array  Consider the following code below. The function printArray accepts a pointer to integer which represents an array of integer.After
 

 

 

DMCA.com