1

I made a 2D array with the plans of using it as a table of doubles that interact with each other in different ways. The problem I have come across is that [0,0] is not needed ([x,0] in the table is the numbers that the Y axis represents and [0,x] is the numbers that the X axis represents)

What I am hoping to achieve is to somehow change [0,0] so that it will either be a String to describe the table I'm printing out or to leave it blank, rather than 0 if left null or otherwise inputted. I've tried using a simple method bringing in the double and checking if it's some chosen number unlikely to be calculated within the table and outputting it as a String, but I'm obviously running into the wall of incompatible types (required String, found double)

1 Answer 1

3

You can't store a String in a double.

What you can do is create a class that holds a string and your double array.

public class NamedArray {
    private String description;
    private double[][] array;
}

You can fill in the getters, setters, and constructors.

Edited to add: I just noticed you're wasting most of the space in your double array.

You can use a List of java.awt.Point instances to represent a series of x and y coordinates. Something like this:

List<ChartValue> array;

public class ChartValue {
    double value;
    Point location;
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.