Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need help with array lists Posted by endrik87 on 15 Jan 2011 at 8:54 AM
Im calculating x and y values and I need to put these into Array lists, what im doing wrong?
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Arvutused {
	static ArrayList<Double> listx = new ArrayList<Double>();
	static ArrayList<Double> listy = new ArrayList<Double>();
	
	public Arvutused() {

		double x, y, t = 10.0, samm = 0.1;

		while (t >= -10.0) {

			t = t - samm;

			x = xValue(t);

			y = yValue(t);

			listx.add(new Double(x));
			listy.add(new Double(y));
		}
	}

	/**
	 * X values calculating.
	 * 
	 * @return x väärtus
	 */
	public static double xValue(double t) {

		double x = 50.0 * Math.pow(Math.cos(Math.PI * (t / 10.0)), 3);
		return x;

	}

	/**
	 * Y values.
	 * 
	 * @return y value
	 */
	public static double yValue(double t) {

		double y = 50.0 * Math.pow(Math.sin(Math.PI * (t / 10.0)), 3);
		return y;
	}
}


Report
Re: Need help with array lists Posted by javabuddy on 15 Jan 2011 at 10:29 PM

you have put your code in Constructor and don't have a public static void main(String args[]) method so your program can not run until you get this method also to run the code from your constructor you need to create an object of your class using new() operator.

Thanks
Javin
Report
This post has been deleted. Posted by javabuddy on 15 Jan 2011 at 10:34 PM
This post has been deleted.
Report
This post has been deleted. Posted by javabuddy on 15 Jan 2011 at 10:46 PM
This post has been deleted.
Report
Re: Need help with array lists Posted by endrik87 on 16 Jan 2011 at 2:25 AM
thanks, I figured it out.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.