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
| package com.behindjava; | |
| public class MyBook { | |
| private int id; | |
| private String bookName; | |
| public MyBook() { | |
| System.out.println("Java"); | |
| } |
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
| Functional programming is a programming style in which computations are codified as functional programming functions. A computation in functional programming is described by functions that are evaluated in expression contexts. These functions are not the same as the functions used in imperative programming, such as a Java method that returns a value. Instead, a functional programming function is like a mathematical function, which produces an output that typically depends only on its arguments. Each time a functional programming function is called with the same arguments, the same result is achieved. Functions in functional programming are said to exhibit referential transparency. This means you could replace a function call with its resulting value without changing the computation's meaning. | |
| Functional programming favors immutability, which means the state cannot change. This is typically not the case in imperative programming, where an imperative function might be associated with state (such as a Java ins |
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
| Java 11 Main features | |
| Java String Utility Methods | |
| isBlank() – This instance method returns a boolean value. Empty Strings and Strings with only white spaces are treated as blank. | |
| System.out.println(" ".isBlank()); //true | |
| System.out.println(s1.isBlank()); //true | |
| lines() | |
| This method returns a string array which is a collection of all substrings split by lines. |
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.BufferedReader; | |
| import java.io.InputStreamReader; | |
| import java.util.Arrays; | |
| public class PolygonArea { | |
| public static void main(String[] args) throws Exception { | |
| //System.out.println("Enter the total number of sides:"); | |
| BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in)); | |
| Integer totalSides = Integer.parseInt(br1.readLine()); |
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
| public class FileReadTest { | |
| public static final String LOG_PATTERN = "^([\\w|\\-.]+)(\\s)"; | |
| public static void main(String[] args) throws IOException { | |
| long starttime = System.currentTimeMillis(); | |
| final Map<String, LongAdder> ipCount = new HashMap<String, LongAdder>(); | |
| Path filePath = Paths.get("F:\\temp\\19950630.23-19950801.00.tsv"); | |
| Files.readAllLines(filePath) | |
| .parallelStream() // Start streaming the lines |
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
| public class FileReadTest { | |
| public static final String LOG_PATTERN = "^([\\w|\\-.]+)(\\s)"; | |
| public static void main(String[] args) throws IOException { | |
| File file = new File("F:\\temp\\19950630.23-19950801.00.tsv"); | |
| long starttime = System.currentTimeMillis(); | |
| final Map<String, Integer> ipCount = new HashMap<String, Integer>(); | |
| Scanner sc = new Scanner(file); | |
| while (sc.hasNextLine()) { |
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
| public class FileReadTest { | |
| public static final String LOG_PATTERN = "^([\\w|\\-.]+)(\\s)"; | |
| public static void main(String[] args) throws IOException { | |
| File file = new File("F:\\temp\\19950630.23-19950801.00.tsv"); | |
| long starttime = System.currentTimeMillis(); | |
| final Map<String, Integer> ipCount = new HashMap<String, Integer>(); | |
| BufferedReader br = new BufferedReader(new FileReader(file)); | |
| String st; |
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
| public class FileReadTest { | |
| public static final String LOG_PATTERN = "^([\\w|\\-.]+)(\\s)"; | |
| public static void main(String[] args) throws IOException { | |
| File file = new File("F:\\temp\\19950630.23-19950801.00.tsv"); | |
| long starttime = System.currentTimeMillis(); | |
| final Map<String, Integer> ipCount = new HashMap<String, Integer>(); | |
| BufferedReader br = new BufferedReader(new FileReader(file)); | |
| String st; |
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
| class Contact { | |
| private String name; | |
| private String phone; | |
| public Contact(String name, String phone) { | |
| this.name = name; | |
| this.phone = phone; | |
| } | |
| public boolean equals(Object contact) { | |
| Contact anotherContact = (Contact)contact; |
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
| class Contact { | |
| private String name; | |
| private String phone; | |
| public Contact(String name, String phone) { | |
| this.name = name; | |
| this.phone = phone; | |
| } | |
| public boolean equals(Object contact) { | |
| Contact anotherContact = (Contact)contact; |