-3

I have three variables a b c. I want a way (in java) of selecting the Min of these variables and adding 1 to it without using an array to sort the values.

Is there a way to do this ?

At the beginning of the program all these variables will be equal to zero.

lilroo
  • 2,928
  • 7
  • 25
  • 34

2 Answers2

5

Math.min(Math.min(a,b), c) + 1

vladr
  • 65,483
  • 18
  • 129
  • 130
2
int a = 1;
int b = 2;
int c = 3;

int min = Math.min(a, Math.min(b, c)) + 1;
Kai
  • 38,985
  • 14
  • 88
  • 103