double,int in Vector ?


    Sponsored Links


  • 1. grid making using jsp
    i want to use a grid in my front end using java. in this grid i want to fetch the information from the database. can i make such a grid using jsp. if yes, can anybody tell me how? ashutosh
  • 2. Darryl Pierce
    Darryl L Pierce aka The Village Idiot

double,int in Vector ?

Postby EVA » Sat, 19 Jun 2004 19:42:00 GMT

I want use a dynamical table in Java for the saving of values (in type
double, int..).
And I want to can use this table to extract the saved values for mathematic

I have try Double type , Int type in a Java Vector,  but it is unusable for
the calculus.

Question : how do you process to solve this problem with a simple manar ?

Re: double,int in Vector ?

Postby VisionSet » Sat, 19 Jun 2004 20:15:12 GMT


You can only store Objects in Collections, double and int are primatives,
not objects.  You must store there wrapped equivalent ie Double or Integer.

wrapping is easy:

Double myDouble = new Double(myDoublePrimative);

unwrapping is easy:

double myDoublePrimative = myDouble.doubleValue();

You must unwrap to be able to use the value in calculations.

I believe that with Java1.5 there is a simple language mod to make this
boxing and unboxing automatic.

Re: double,int in Vector ?

Postby Yu SONG » Thu, 24 Jun 2004 21:07:34 GMT

See java.math.*


/* E-mail.c */
#define User            "Yu.Song"
#define Warwick         ""
int main() {
printf("Yu Song's E-mail: %s@%s", User, Warwick);
return 0;}

Further Info. :    http://www.**--****.com/ ~esubbn/

Similar Threads:

1.Line2D.Double(double X1, double Y1, double X2, double Y2)

Jenny wrote:

> In Line2D.Double(double X1, double Y1, double X2, double Y2), the
> parameter are doubles.  A pixel has no fraction value.  Why does it
> use doubles?

The object models a line in 2D space. Plotting the line
in an integral based device is just one appliance.

What makes this confusing is the strange connection between
these general concepts and the AWT. The package "java.awt.geom"
should really be "java.geometry"; Apart from PathIterator
(which should be in java.awt) all classes are generic and
GUI independent.

Who invented the term "geom" anyway?

2.java3D: Canvas3D.setBounds(int int int int);

I'm trying to display a Canvas3D in  JTable. Following problem occurs: 
As you can see in the source code below I'm extending the class Panel 
(or JPanel). In my class J3DPanel I'm using a Canvas3D and setting the 
bounds. Assigning my class to a Frame will always fill the full Frame 
with the Canvas3D, despite to my calls to setBounds, setSize etc.

My question: Is there any way to set the size and location of an 
Canvas3D so I can display it inside a JTable?

I'm using a Macintosh with OS X if this is of interest.



package sse;

import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import javax.swing.JPanel;
import java.awt.Panel;
import java.awt.Rectangle;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.*;
import com.sun.j3d.utils.universe.*;
import javax.vecmath.*;

public class J3DPanel extends Panel {
    SimpleUniverse universe = null;
    Canvas3D canvas  = null;

    public J3DPanel() {

    public void setBounds(int x, int y, int width, int height) {
        super.setBounds(x,y,width, height);
        canvas.setBounds(x, y, width, height);

    public BranchGroup createSceneGraph() {
        BranchGroup RootBG = new BranchGroup();
        TransformGroup SphereTG = new TransformGroup();
        Transform3D SphereT3D = new Transform3D();
        Appearance SphereAppearance = new Appearance();

        AmbientLight ALgt = new AmbientLight(new Color3f(1f, 1f, 1f));
        DirectionalLight DLgt = new DirectionalLight(new Color3f(1f, 1f, 1f),
                new Vector3f( -0.5f, -0.5f, -1f));
        BoundingSphere BigBounds = new BoundingSphere(new Point3d(), 100000);


        SphereT3D.setTranslation(new Vector3f(0f, 0f, -1.5f));
        SphereAppearance.setMaterial(new Material(new Color3f(0f, 0f, 1f),
                                                  new Color3f(0f, 0f, 0f),
                                                  new Color3f(1f, 0f, 0f),
                                                  new Color3f(1f, 1f, 
1f), 100f));
        SphereTG.addChild(new Sphere(1.0f, Sphere.GENERATE_NORMALS, 40,

        return RootBG;

    public void init() {
        setLayout(new BorderLayout());
        GraphicsConfiguration config = 
        canvas = new Canvas3D(config);

        Rectangle r;
        System.out.println("Rectangle:" + r.x + " " + r.y + " " + 
r.width + " " + r.height);

        add("Center", canvas);
        universe = new SimpleUniverse(canvas);

} to read XML configuration parameters, bool, int, double, string

4.internal int to double cast

Hi there,

I just want to have a confirmation. I have two
variables like this:
	int i = 10;
	double d = 10.1;

Now I test whether d is greater and do such a thing:
	if (i<d)

My question is the following. Does Java internally
converts the int(eger) i to double before comparison
(as I assume it does) or might there be circumstances
where it did not in such a case?

Best regards,

5.Number format exception while converting from double to int

The code
int n = (int) java.lang.Math.round(Double.parseDouble((String)
		r = (int) java.lang.MathException in thread "main"

resulted in the following ex:
java.lang.NumberFormatException: For input string: "5.0"
	at java.lang.Integer.parseInt(
	at java.lang.Integer.parseInt(

The args.get(0) represents "5.0" as input. I have tried the most common
int n = Integer.parseInt((String) args.get(0));
but eventually failed and later evolved to the version as at the front
of this post. BTW, I use JAVA REFLECTION to do so. The code is inside a
class which is called by a reflection procedure.
What is it going wrong? Thx~!

6. "rename/redefine" int, double, etc in java?

7. typecasting double --> int

8. Double to Int and back

Return to JAVA


Who is online

Users browsing this forum: No registered users and 32 guest