# how to find subarray from given large 2d array of arbritary dimension

my code is: import java.lang.*; import java.io.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class SubMatrix { public static void main(String[] args) throws IOException {

```    File file = new File("file1.txt");
List<float[]> list = new ArrayList<float[]>();
Scanner scanner = new Scanner(file).useDelimiter("\n");

while (scanner.hasNext()) {
String[] values = scanner.next().trim().split(" ");
float[] floats = new float[values.length];
for (int i = 0; i < values.length; i++) {
floats[i] = Float.parseFloat(values[i]);
}
}
float[][] values = new float[list.size()][];
for (int i = 0; i < list.size(); i++) {
values[i] = list.get(i);
for (int j = 0; j < values[i].length; j++) {
System.out.print(values[i][j] + " ");

}
System.out.println();
}

int row =values.length;
int col=values.length;
```

//*******************************

```              int subrow;
System.out.print("Enter the number for rows :");

double subArray[][] = new double[subrow][col];

for(int k=0;k<subrow;k++){
for(int p=0;p<col;p++){

System.arraycopy(values,0,subArray,0,subrow);
System.out.print(subArray[k][p] + " ");
}
System.out.println();
}

}}
```

and .txt file is: 1.0 3.1 2.1 3.4
2.4 2.0 4.6 5.1
0.2 3.3 4.7 9.1
4.0 5.4 5.1 3.2
6.1 2.1 6.4 2.6
1.2 2.0 3.5 6.9
3.1 2.5 4.6 9.8
7.1 8.1 9.4 5.1
12.1 3.1 2.5 2.4
3.8 9.1 2.1 6.7

i want to print the subarray of any dimension from given array file. i have tried upto above code but it gives runtime error as: NumberFormatException:empty string. error might be on "floats[i] = Float.parseFloat(values[i]); " line.help wud be apprec.

Related Tutorials/Questions & Answers:
how to find subarray from given large 2d array of arbritary dimension
how to find subarray from given large 2d array of arbritary dimension ... to print the subarray of any dimension from given array file. i have tried upto...(br.readLine()); double subArray[][] = new double[subrow][col
how to find inverse of n*n 2d array in java
how to find inverse of n*n 2d array in java  I reached upto code of printing the matrix as: Assume that matrix is square matrix where row=column code is: public class ReadContents{ public static void main(String args
how to print the content of file in 2d matrix having same dimension as given in file(n*m).
how to print the content of file in 2d matrix having same dimension as given in file(n*m).   here is code: import java.io.File; import... of any dimensions in the form of 2d n*m matrix. pls help me
array find all possible dimension
array find all possible dimension  Given array: int[] dimension = { 1, 2, 3 }; That produces the output: 1 2 3 12 13 23 123 I'm new to array...i can't figure out the way on even how to start... any idea?...really appreaciate
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your program
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your program
Find Array element from index using GUI
Find Array element from index using GUI In this tutorial, you will learn how to create an GUI application to find an array element from its index. For this, we have created an an array of 100 randomly chosen integers and allow
how to create unit matrix in java of arbritary dimensions
how to create unit matrix in java of arbritary dimensions  i want to create the unit matrix of arbritary dimensions say (n*m).i m a new beginner to java.someone having the program for that? help would be appreciable
Selecting elements of 2D array with GUI
Selecting elements of 2D array with GUI  Hello! I am building... or selected elements of below 2D array (images attached): Year Season 2002 2003... how start with the code for displaying elements of the array selected by user
Storing the Color Image pixel values into 2d array
Storing the Color Image pixel values into 2d array  i want to store the color image pixel values into 2d array and agiain the array have to store into a text file using java... plz provide the code
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... in the given file having say n*m matrix.   import java.io.File; import
JavaScript array dimension
JavaScript array dimension       In this code we help you to understand array dimension... to make a Two dimension array. The page on loading invoke a function display
How to read data dynamically from keyboard to array in flex
How to read data dynamically from keyboard to array in flex  How to read data dynamically from keyboard to array in flex
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...;; There are some methods of array that can use in array like length() can find
sql php array
; SQL PHP Array support simple dimension array. The SQL PHP Array is used to populate array from MySQL database. Understand with Example  The Tutorial illustrate an example from 'SQL PHP Array'. To understand and grasp
how insert data from databse in array and compare new data to already stored value in array
how insert data from databse in array and compare new data to already stored value in array   hello all i tried to fetch data from databse and try to stored it in an array and i want to compare new value that come from database
find the given input is integer or string
find the given input is integer or string  simple coding for to check the given input value is integer or no.If the given value is integer display "Value is integer" otherwise "Value is not a integer"?   class
How to send boolean array to servlet from java application?
How to send boolean array to servlet from java application?  Hi, I want to send randomly generated array of boolean values. I used Random function and boolean array length to generate values. My question is I want to send
Find out last character of array
Find out last character of array  How we can find out the last character of array in java program
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... sample code for how to retrive array values from html to jsp.   hi friend... it into jsp. Means i just want to retrieve values from html form containing array
how to call the array variable in scriptlet from javascript function
how to call the array variable in scriptlet from javascript function  This is the scriptlet code:- <% String[] abc={"saab","volvo","bmw","Benz","Porsche","Jaguar"}; %> Actually i want the array variable one by one
create associative array from array javascript
create associative array from array javascript  How to create associative array from an array in JavaScript? Please suggest. Thanks
How To Remove Array Element In Java
will demonstrate you about how to delete an element from array. To remove the array...How To Remove Array Element In Java In this section we will discuss about how to remove a given array element. In this section we will discuss about removing
ModuleNotFoundError: No module named 'subarray'
'subarray' How to remove the ModuleNotFoundError: No module named 'subarray...ModuleNotFoundError: No module named 'subarray'  Hi, My Python... to install padas library. You can install subarray python with following
ModuleNotFoundError: No module named 'subarray'
'subarray' How to remove the ModuleNotFoundError: No module named 'subarray...ModuleNotFoundError: No module named 'subarray'  Hi, My Python... to install padas library. You can install subarray python with following
How to pass Array of string from action class to jsp page
How to pass Array of string from action class to jsp page  this is my... = con.createStatement(); rs = st.executeQuery("SELECT * FROM user_charges...("SELECT * FROM user_charges WHERE TEST_CODE="+tcode); while (rs.next
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
Create list from array in Java
Create list from array in Java  Hi, I have an array with some data. How to Create list from array in Java? Thanks   Hi, Here is example of creating of creating an array: String[] names = new String[]{"Java", "JSP
To find first two maximum numbers in an array
To find first two maximum numbers in an array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Display set of names from array
Display set of names from array In this section, you will learn how to display the set of names from array. In the given code, we have declared an array... element, it will display the set of countries name from the array. Example
how to pass string array from action class to jsp page? pls reply me.
how to pass string array from action class to jsp page? pls reply me.  how to pass string array from action class to jsp page? pls reply me.  ...); And through your jsp page, get array values. <% try { String[] str = (String
Finding an Element in a Sorted Array
. In this section, you will learn how to sort an array and how to find a text in the sorted... an searching an elements in the array. This example takes some inputs from the user... that. And it show the given text position in the array, if text is present
Call an array from multiple functions
Call an array from multiple functions  I am having two methods in this method i am getting array values from another class. i create same array name for accessing the method values(array) but it will access only one method values
How to: generic array creation
How to: generic array creation  How to: generic array creation
C Array of String
C Array of String       In this section you will learn how to create an array of string in C... and handled like a 2d(two dimensional) arrays. You can see in the given example that we
shortest path from the given source to dstination
to find the shortest path from the given source to destination based on the databse values. How do I do? Please report quickly. Thanks in advance...shortest path from the given source to dstination  Hi. Here in my
How to Split a large XML file using java?
How to Split a large XML file using java?  How can we split a 500MB Xml file?I know how to split xml file after reading the entire document in a file.Here we cannot load the entire file as it is a large file
Get Array Size
;    To calculate length of the given array we have used length property. It returns the length of the given array. In this tutorial we have...;Saturday"}; We have used these two types of array and the explained you how to get
Find in Array - Calculate Occurrences of Elements in Array
Find in Array - Calculate Occurrences of Elements in Array... to calculate occurrences of elements in an array. Occurrences means, the how many... help from the given following program with the complete code. Program
ModuleNotFoundError: No module named 'ska-sdp-subarray'
named 'ska-sdp-subarray' How to remove the ModuleNotFoundError: No module named 'ska-sdp-subarray' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'ska-sdp-subarray'  Hi, My
How to Prepend Array in PHP
How to Prepend Array in PHP  hi, How can i prepand array in PHP. Please suggest any example of prepand array in PHP program. Thanks,   Hi, The PHP prepand array function in used before adding any elements
Array Name
Array Name  How To Set Value in Two-Dimension ArrayList
Java get byte array from file
Java get byte array from file  what is the code example in Java for getting byte array from file in memory. Thanks   This is very simple code in Java. Following tutorials will teach you how to achieve this. Java
is this programm efficient to find the day of the given date . can it be more normalized ?
is this programm efficient to find the day of the given date . can it be more normalized ?  #include <stdio.h> int main(void) { int dd,mm,yy,i,leap=0,ordi=0,odd_years,month_days= 0,total ; char week[10
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
To find first two maximum numbers in an array,using single loop without sorting array.
To find first two maximum numbers in an array,using single loop without sorting array.  Java program to find first two maximum numbers in an array,using single loop without sorting array
How to Convert ArrayList to Array?
How to Convert ArrayList to Array?  Hi, I am trying to learn to Convert ArrayList to Array. How it is possible? How to Convert ArrayList to Array? Thanks   Hi, To Convert ArrayList to array ArrayList.toArray
how do i begin a two dimensional array?
how do i begin a two dimensional array?  I'm new to java programming and need to create a two dimensional array that enters exactly what is entered in the first dimension and then the first non-white space character of what
how to create array in r
how to create array in r  Hi, In R Programming how array is created? how to create array in r? Explain me the process of array creation using the examples. Thanks   Hi, In R Programming language array is used
Objective C Array
and remove the objects from the given list of array if the array is declared mutable. Syntax to declare an Array in Objective C: NSArray *myArray...Objective C Array In a simple term we can say that array is a object, which