149k views
5 votes
Write a class named Location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two dimensional array with row and column as int type and maxValue as double type. The class also contains a constructor Location(row, column, maxValue) for creating an instance with the specified row, column, and maxValue.

User Imelda
by
7.5k points

1 Answer

6 votes

Answer:

public class Location {

//Class member (instance) variables

public int row;

public int col;

public double maxValue;

//The constructor

public Location(int row, int col, double maxValue) {

this.row = row;

this.col = col;

this.maxValue = maxValue;

}

}

Step-by-step explanation:

  • Above is the solution in Java
  • The three instance variables are created with public access modifier, and respective data types as required by the question
  • A constructor that initializes the three fields is also created.
User Prasanna
by
6.9k points