We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// For loop publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);for(inti=1;scan.hasNext();i++){System.out.println(i+" "+scan.nextLine());}}
You don't have to use the == operator to compare with true since the hasNext method returns a boolean.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java End-of-file
You are viewing a single comment's thread. Return to all comments →
Your for loop can be simplified:
You don't have to use the == operator to compare with true since the hasNext method returns a boolean.