how do you write % in Java

Edited 6 Years Ago by jackieoh: n/a

Hi jackieoh and welcome to DaniWeb :)

Not sure exactly what your question means, but if you want to output "%" character to the console you do this:

System.out.print("%");

If that's not what your question meant, please let us know what you are trying to do.

Hi jackieoh and welcome to DaniWeb :)

Not sure exactly what your question means, but if you want to output "%" character to the console you do this:

System.out.print("%");

If that's not what your question meant, please let us know what you are trying to do.

I am trying to debug some exercises. One line says: result =
a % b; I am lost. It keeps saying that I am loosing precision. this is all new to me and i am lost. LOL

I am trying to debug some exercises. One line says: result =
a % b; I am lost. It keeps saying that I am loosing precision. this is all new to me and i am lost. LOL

Forgive me for not thanking you for the welcome.

So that's how I write it in debugging exercise?

The % or modulus operator gives, as its answer, the remainder after division. So 3 % 3 = 0 and 3 % 2 = 1 and 11 % 3 = 2

int a = 5;
int b = 3;
int result = a % b;
System.out.println(result); //prints 2

If you need to know anything else, ask a better question.

This article has been dead for over six months. Start a new discussion instead.