Академический Документы
Профессиональный Документы
Культура Документы
import java.io.*;
import java.util.*;
class Employee{
public int id;
public String name;
public String address;
public static int count = 0;
public Employee(){}
public Employee(int id, String name,String address) {
super();
this.id = id;
this.name = name;
this.address=address;
count++;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
}
public class DisplayArrayList {
}
}
}
}
----------------------------------------------------------------
String data;
String[][] matrix = new String[4][4];
this.matrix[i][j] = next;
}
}
}
}
catch(Exception e)
{
String s = e.toString();
System.out.println(s);
}
}
--------------------------------------------------------------------------
asList(): asList() is a method of Array class that takes an array of any type as
parameter and returns a fixed-size list of the elements of the specified array.
import java.io.*;
import java.lang.*;
import java.util.*;
}
}
}
-----------------------------------------------------------------------------------
------------
1. read size that you want to define 2D array from file
2. bring it in declare object array size
//this example program read size 2D array from file "dat.txt"
import java.io.*;
class aarr{
public static void main (String[] asg) throws IOException{
int n = (int)d;
double [][] a = new double[n][n];
for(int i = 0;i<n;i++){
for(int j=0;j<n;j++){
a[i][j] = 1.234;
}
System.out.println(i);
}
}
}
-----------------------------------------------------------------------------------
-
Hope this code helps somewhat.
import java.io.*;
public class Tester {
}
}
----------------------------------------------------------------------
public class MultiplicationTable{
public static void main(String[] args) {
int[][] array = new int[11][11];
for (int i=1; i<array.length; i++) {
for (int j=1; j<array[i].length; j++) {
array[i][j] = i*j;
System.out.print(" " + array[i][j]);
}
System.out.println("");
}
}
----------------------------------------------------------
int[][] a2 = ...;
// Local varaibles
int rowCount;
int colCount;
int totalSize;
//*************************
// ragged arrays
//*************************
// First allocate the rows of an array
byte[][] raggedArray = new byte[5][];
//************************************
// static array initialization
//************************************
byte[][] smallArray = { { 10, 11, 12, 13 }, { 20, 21, 22, 23 },
{ 30, 31, 32, 33 }, { 40, 41, 42, 43 }, };