so say I have
x and y
40and 200
20and 100
49and 23
Say the user inputs 40 and clicks a button. I need to tell the program to return 200.
How do i store those 3 x values w/ their corresponding y values ? I have to use java.awt.point. Does point work with arrays or list ?
Message was edited by:
va97
tjacobs01
Some of us are not experts, which is why we seek help to understand some topics that were not covered in class. Topics that the books I have don't discuss much about.
One can't learn everything there is to know about Java.
I am new to this forum so if you don't want to help, by all means you don't have to answer but try not to talk or look down at others.
Thanks
Message was edited by:
va97
> I am new to this forum so if you don't want to help,
> by all means you don't have to answer but try not to
> talk or look down at others.
va don't get so upset. It's not like I'm laughing with you; I'm laughing at you.
go go go - get your troll on (I should be a rapper or a dj or something)
:)
Hopefully, someone can enlighten me ?
I have an array of point
int[] depth = {25, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190};
int[] minutes = {595, 405, 310, 200, 100, 60, 50, 40, 30, 25, 20, 15, 10, 10, 5, 5, 5, 5, 5};
Point[] points = new Point[depth.length];
for(int i = 0; i < points.length; i++)
{
points[i] = new Point(depth[i], minutes[i]);
}
JTextField tfXvalue = new JTextField();
String getXvalue = tfdepth.getText();
Say the input of getXvalue is 40. Then I do all of the necessary conversions from string to double etc...
I need to tell the program to look in the array, and return the Y value where X=40.
I haven't the slightest idea where to start. !!!!
Would someone mind pointing me in the right direction ?
Message was edited by:
va97
i'm currently having a problem with my Point array.
after looking at threadstarter program, i'm getting more confused ?
Point[] points = new Point[10];
for(int i = 0; i < 10; i++){
point = new Point(x, y);
}
why did we need to create new instance of the Point the 2nd time?
for example... i can do this
char character = new char[10];
character[0] = 'a';
BUT i can't do the same for
Point point = new Point[10];
point[0].setLocation(x, y);
WHY? i thought that by default the Point value should be (0,0) and yet my compiler threw me an exception :(
Because char is a primitive, not a reference. You can think of references as effectively just another type of primitive with a default value of null.
When you're dealing with that Point array, you don't instantiate anything twice. The "new Point[n]" statement instantiates the array object, with space for n references, which must be of type Point, all initially null. The "new Point(x, y)" statement instantiates a Point object, whose reference you then place in one of the n elements of the array.