Java AtomicInteger getAndIncrement() methodThe getAndIncrement() method of Java AtomicInteger class gets the value first and increment it by one. SyntaxReturnThis method returns the previous value. Example 1Test it NowOutput: the updated number: 1 the previous number: 0 Example 2Test it NowOutput: the updated number: 11 the previous number: 10 Example 3Test it NowOutput: the updated number: 2 the previous number: 1 Example 4Test it NowOutput: the updated number: 0 the previous number: -1 Example 5Test it NowOutput: the updated number: -3 the previous number: -4 Next TopicJava AtomicInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India