java语言程序设计第8版答案
【篇一:java语言程序设计基础篇(第八版)编程8.5答
案】
public class testlocation {
public static void main(string[] args) { // todo auto-generated method stub
system.out.println(enter the number of rows and colums of the array :);
scanner input = new scanner(system.in); int row = input.nextint();
int column = input.nextint();
system.out.println(enter the array);
double[][] array = new double[row][column]; for(int i=0 ;i array.length;i++){ for(int j=0 ;j array[i].length ;j++ ){ array[i][j] = input.nextdouble(); } }
location location = new location(); location.locatelargest(array);
system.out.println(the location of the largest is +location.getmaxvalue()+ at (+location.getrow()+ , +location.getcolumn()+)); } }
class location{
private static int row ;
private static int column ;
private static double maxvalue ; public int getrow() { return row; }
public void setrow(int row) { this.row = row; }
public int getcolumn() { return column; }
public void setcolumn(int column) { this.column = column; }
public double getmaxvalue(){ return maxvalue; }
public static location locatelargest(double [][] a ){row = 0; column = 0; maxvalue = 0;
for(int i= 0 ;i a.length ;i++){
for(int j=0 ;j a[i].length ; j++){ if(a[i][j] maxvalue){ maxvalue = a[i][j]; row = i ;
column = j; } } }
return null;//题目中说要返回一个location 的实例,我不知道咋返回 } }
【篇二:java语言程序设计第九版第八章答案】
1. 2.
public class classname { }
the syntax to declare a reference variable for an object is
classname v;
the syntax to create an object is new classname();
constructors are special kinds of methods that are
called when creating an object using the new operator. constructors do not have a return type—not even void. a class has a default constructor only if the class does not define any constructor.
the member access operator is used to access a data
field or invoke a method from an object. the syntax to define a class is see the section defining classes for objects. 3. 4. 5. 6. 7.
8. an anonymous object is the one that does not have a reference variable referencing it.
9. a nullpointerexception occurs when a null reference variable is used to access the members of an object. 10. an array is an object. the default value for the elements of an array is 0 for numeric, false for
boolean, ?\