Java AtomicInteger getAndSet( ) methodThe getAndSet() method in Java AtomicInteger class sets the new value to the given atomicInteger and returns the old value. SyntaxParametersnewValue: It is new value. ReturnIt will return the current value of atomicInteger. Example 1Test it NowOutput: the updated number: 20 the old number: -10 Example 2Test it NowOutput: the updated number: 20 the old number: 0 Example 3Test it NowOutput: the updated number: 200 the old number: 100 Example 4Test it NowOutput: the updated number: 2 the old number: 10 Example 5Test it NowOutput: the updated number: -3 the old number: 10 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