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




Have Programming Question? Ask it here!
 
 
 


Louis Christopher
Array Strings
1 Answer(s)      a year and 9 months ago
Posted in : Java Beginners


String auto[]=new String[]{"Length: ","Breadth: ","Height: "}; in the above code i can easily input values into my string auto which is a single dimensional array. How do you do this with a two dimensional array? for eg: String auto[][]=new String[][]{"Length: ","Breadth: ","Height: "}{"Length: ","Breadth: ","Height: "};

the above code generates error. please help!


Advertisement
View Answers

December 4, 2012 at 5:06 PM


Here is an example that input values to 2 dimensional array. Here we have defined an array of 2 rows and three columns.

import java.util.*;
class TwoD 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter array elements: ");
        String auto[][]=new String[2][3];
        for(int i=0 ; i < auto.length ; i++)
          for(int j=0 ; j < auto[i].length ; j++){
          auto[i][j] = input.next();
        }
        for(int i=0 ; i < auto.length ; i++){
            System.out.println();
            for(int j=0 ; j < auto[i].length ; j++){
                System.out.print(auto[i][j]+" ");
            }
        }
    }
}


Related Tutorials/Questions & Answers:
Array Strings
Array Strings  String auto[]=new String[]{"Length: ","Breadth: ","Height: "}; in the above code i can easily input values into my string auto which is a single dimensional array. How do you do this with a two dimensional array
Java create new array of strings.
Java create new array of strings.  Java create new array of strings...); } } } Description: Array is container which holds fix length of any kind of data type...] name is an String type array can hold 7 values. You can also
Advertisements
use strings as array indexes using JavaScript
use strings as array indexes using JavaScript  How to use strings as array indexes using JavaScript
strings
strings  difference between the strings in java and c
Strings
a static method that returns the Sting array and takes a String as parameter.... This method will split the string with "," as a delimiter. the return String array will contain strings which is separated by ",". From the main method invoke
strings
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2... is an example which accept two strings as command line arguments and perform
strings
(char[] array, int amount) { for (int j = 0; j < amount; j++) { char a = array[0]; int i...++) array[i] = array[i + 1]; array[i
strings
strings   read sentence and convert all the word into capital case like camelcase   Hi Friend, Try the following code: import java.util.*; class ConvertWordsIntoUpperCase { public static String toCamelCase(String
strings
strings  Write a program to initialize 7 names in an array and their respective roll numbers in another array. Search for a roll number input by the user ,in the list ,If found display "Search Successful" and print the name along
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
Strings in PHP
Strings in PHP  Hi, I am beginners and want to know about strings in PHP and different ways to print a string. Can someone help me in this regards?   Following tutorials will help you in details about strings in PHP
strings concatnation
strings concatnation  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic
strings in java
strings in java  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1
strings 20june
strings 20june  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello
Java insertion sort with string array
Java insertion sort with string array In this tutorial, you will learn how to sort array of strings using string array with Insertion Sort. For this, we... the method and pass array of strings to it. Example: public class
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
split strings in php
split strings in php  how can i split strings in word pair in PHP
compare two strings in java
compare two strings in java  How to compare two strings in java...) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two
array string
array string  how to sort strings with out using any functions
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
To check the Rotational Strings are Equall or not
To check the Rotational Strings are Equall or not  I attended 3dplm software company interview....there asked one question related to Strings.The question is................. Write a program to check the given two strings
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
Iphone Comparing Strings
Iphone Comparing Strings  Hi, I am very new in the mobile application programming. I have trying to develop a small application for IPhone SDK Comparing Strings. Could any one suggest or provide any examples topics iphone sdk
convert numbers to strings using JavaScript
convert numbers to strings using JavaScript  How to convert numbers to strings using JavaScript
Grouping strings - Java Beginners
Grouping strings  I have written a code to determine the lengths of strings. What I need to do is to group strings that are within a certain range, say 15 to 20, 21 to 30, etc. Is there any one out there with an idea?  
Strings - Java Beginners
Strings  Normally when we assign one object to the other, a copy of the reference is created and both these references point to the same object. eg: Obj o1=new Obj(); Obj o2=o1; But is case of Strings, how
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
strings - Java Beginners
strings  how can i write an example of string arrays with loop function without declearing inputs  Hi Friend, Try the following code which shows how to create an array of String and prints the array elements. Code
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
Array
Array  can we create an array of size 1 lakh in java programming
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
searching for strings in a file
searching for strings in a file  how can i search of a person and display the other details associated with the name using java gui window?   import java.util.ArrayList; import javax.swing.*; import java.awt.event.
Appending Strings - Java Tutorials
.style1 { text-align: center; } Appending Strings In java, the two main ways for appending string at the end are : First method is using += operator. Second method is using append()  method. In this section, we
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
 

 

 

DMCA.com