How to take space seperated input from user in java

how to take space seperated input from user in java

@prateek8375 You can use sc.nextInt(); This will automatically searches for next int in your input be it in same line or in any other line.