Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## SUPER SIMPLE QUESTION!!!

I just started me java class and im confused about how powers work, such as

Volume of Cylinder = PIE (radius)2(SUPPOSED TO BE SQUARE, NOT 2) *height

how does the above translate to java code? specificly the power of 2, sry im stupid, thx

2. ## Re: SUPER SIMPLE QUESTION!!!

For exponents you use:
`Math.pow(A, B); //A is the original number. B is to what power`

3. ## Re: SUPER SIMPLE QUESTION!!!

Take a look at the Java Platform SE 6 class. Most notably the pow method.

4. ## Re: SUPER SIMPLE QUESTION!!!

I always write squares out (in my mind this is faster and more accurate, but not by much)

Mmm, PIE. It's actually PI, and you can use Math.PI for the floating point representation of this number. Also, in Java you must explicitly spell out everywhere you're performing a multiplication/add/etc.

```double a = 3;
double b = 3a; // error
double b = 3 a; // error
double b = 3 * a; // correct```

5. ## Re: SUPER SIMPLE QUESTION!!!

Volume of Cylinder = PI(radius)2(power 2) * height
Surface Area of Cylinder = 2 PI radius * height

ok so im confused on why my teacher would give me the above as a formulas. at my level of math and java programming the above makes no sense.. i can decipher the top one. but 2 pi radius * height.. umm wtf

so its 2 * pi * radius * height? Why have one multiplication symbol and not the rest?

6. ## Re: SUPER SIMPLE QUESTION!!!

Your anwser should look like this

```int height = 2;