Last active
February 4, 2018 17:11
-
-
Save johnludwigm/7d4d457e81c6894f26bc77911ba7eb94 to your computer and use it in GitHub Desktop.
Example of in-line assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Main { | |
public static void main(String[] args) { | |
String fileName = "blog.txt"; | |
FileReader fileReader = new FileReader(fileName); | |
BufferedReader br = new BufferedReader(fileReader); | |
String line; | |
//Observe that line is assigned to br.readLine within this line of code | |
//while another process (comparing to null) is happening. | |
while ((line = br.readLine()) != null) { | |
//process the line, or do whatever. | |
} | |
br.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment