-2

Dividing 10/100 in java gives me an answer of 0

    double s = 10/100;
    System.out.println(s);

I don't understand why that happens , can anyone help me?

Thanks

Chandraaditya
  • 341
  • 1
  • 8
  • 18

1 Answers1

3

just do a casting like this

 double s = (double)10/100;
System.out.println(s);

that'll do. Oh, and do as #SURESH ATTA suggests in the comment.

Armando
  • 459
  • 1
  • 8
  • 22