Java Tutorial 4 - Primitive Types (int and double)

preview_player
Показать описание
TechnicalCafe Blog:

TechnicalCafe Forms:

TechnicalCafe Twitter:

Jamie's Twitter:
Рекомендации по теме
Комментарии
Автор

Hi I love your videos. I have a quick question though,
int a = 5;
double b = 9 / a;
double c = 9.0 / a;

System.out.println (b);
System.out.println (c);

b gives the wrong answer where c gives the correct one.
Even though I'm using a double data type why do I have to use 9.0 as opposed to 9 by itself when doing a calculation with a double divided by an int?

alizamanzadeh
Автор

i get an error "Static Error: This class does not have a static void main method accepting String[] "

i did exactly like you, by the way im using drjava not eclipse

varunsubramanian