1.6 Einführung Java: Operatoren / Introduction Java: Operators

1.6 Einführung Java: Operatoren / Introduction Java: Operators


1. Arithmetische Operatoren:

Die Arithmetischen Operatoren ( +, -, * und /) benötigen wir um Berechnungen zu unternehmen, wie ihr sicher noch aus dem Mathematikunterricht kennt. In Java ist es wichtig wenn ihr Berechnungen machen wollt das die Datentypen immer die selben sind.

Beispiel:

float a = 1.5f;
float b = 23.49f;

float c;

c = a + b;
c = a / b;
c = a - b;
c = a * b;

 

2. Der Modulo - Operator:

Der Modulo - Operator ( % ) gibt einen Rest einer Integer-Division zurück.

Beispiel:

int a = 25;
int b = 12;

int c;

c = a % b;

In diesem Beispiel ist der Rest 1.


3. Inkrementation & Dekrementation:

Die Inkrementation und Dekrementation ( ++, - - ) erhöht oder verringert einen wert um 1.

Beispiel:

int x = 10;

x = x++;

In diesem Beispiel der Inkrementation (Erhöhung) ist das Ergebnis 11.

x = - - x

In diesem Beispiel der Dekrementation (Erniedrigung) ist das Ergebnis 9.

 

English:

 

1. arithmetic operators:

We need the arithmetic operators ( +, -, * and /) to make calculations, as you probably know from mathematics lessons. In Java it is important if you want to do calculations that the data types are always the same.

Example:

float a = 1.5f;
float b = 23.49f;

float c;

c = a + b;
c = a / b;
c = a - b;
c = a * b;

 


2. the modulo operator:

The modulo operator ( % ) returns a remainder of an integer division.

Example:

int a = 25;
int b = 12;

int c;

c = a % b;

In this example, the remainder is 1.


3. incrementation & decrementation:

The incrementation and decrementation ( ++, - - ) increases or decreases a value by 1.

Example:

int x = 10;

x = x++;

In this example of incrementation, the result is 11.

x = - - x

In this example of decrementation (humiliation) the result is 9.

Translated with www.DeepL.com/Translator

How do you rate this article?

0


Conschdi
Conschdi

Im a human. https://bittubers.com/profile/Beautiful-World Peace & Love to everyone.


App entwicklung mit Android Studio in Java
App entwicklung mit Android Studio in Java

In diesem Blog erkläre ich schritt für schritt wie man eigene Apps mit Android Studio in der Programmiersprache Java eigenhändig programmiert. In this blog I explain step by step how to program your own apps with Android Studio in the programming language Java.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.