how do you write % in Java

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.