Skip to content

Instantly share code, notes, and snippets.

@creyn
Created August 25, 2018 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creyn/925d8a391694536a52d102aae5b6b661 to your computer and use it in GitHub Desktop.
Save creyn/925d8a391694536a52d102aae5b6b661 to your computer and use it in GitHub Desktop.
Droga Programisty : Kod : Matematyka w Javie 3
public class OperatoryUnarne {
public static void main(String args[]) {
System.out.println("Operatory unarne\n");
int liczbaA = 5;
// chcemy dodac 10 do naszej zmiennej
// standardowy opeartor
liczbaA = liczbaA + 10;
System.out.println("Liczba A : " + liczbaA);
// opearator przypisania dodatniego
liczbaA += 10;
System.out.println("Liczba A : " + liczbaA);
// teraz odejmujemy 2 od naszej zmiennej
// standardowy operator
liczbaA = liczbaA - 2;
System.out.println("Liczba A : " + liczbaA);
// opearator przypisania ujemnego
liczbaA -= 2;
System.out.println("Liczba A : " + liczbaA);
// teraz chcemy dodawac 1 do naszej zmiennej
// standardowy operator
liczbaA = liczbaA + 1;
System.out.println("Liczba A : " + liczbaA);
// operator przypisania dodatniego
liczbaA += 1;
System.out.println("Liczba A : " + liczbaA);
// operator inkrementacji
liczbaA++;
System.out.println("Liczba A : " + liczbaA);
// i na koniec operator dekrementacji
liczbaA--;
System.out.println("Liczba A : " + liczbaA);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment