Knowledge in java all notes

Java notes for bit student

Check out my other content

Introduction to Java

Java is a modern, evolutionary computing language that combines an elegant language design with powerful features that were previously available primarily in specialty languages. In addition to the core language components, Java software distributions include many powerful, supporting software libraries for tasks such as database, network, and graphical user interface (GUI) programming. In this section, we focus on the core Java language features.

All about JavaScript from basic to advanced.

This file contains about JavaScript definition, Introduction, History, How to run JavaScript?, Advantages, etc.

Java™ : The Complete Reference, Seventh Edition,Herbert Schildt

About the Author Herbert Schildt is a leading authority on the Java, C, C++, and C# languages, and is a master Windows programmer. His programming books have sold more than 3.5 million copies worldwide and have been translated into all major foreign languages. He is the author of the best-selling The Art of Java, Java: A Beginner’s Guide, and Swing: A Beginner’s Guide. Among his other bestsellers are C++: The Complete Reference, C++: A Beginner’s Guide, C#: The Complete Reference, and C#: A Beginner’s Guide. Schildt holds both graduate and undergraduate degrees from the University of Illinois. He can be reached at his consulting office at (217) 586-4683. His Web site is www.HerbSchildt.com. Contents: I The Java Language 1 The History and Evolution of Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 An Overview of Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3 Data Types, Variables, and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 4 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 5 Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 6 Introducing Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 7 A Closer Look at Methods and Classes . . . . . . . . . . . . . . . . . . . . . . . . 125 8 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 9 Packages and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 10 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 11 Multithreaded Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 12 Enumerations, Autoboxing, and Annotations (Metadata) . . . . . . . . . 255 13 I/O, Applets, and Other Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 14 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Part II The Java Library 15 String Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 16 Exploring java.lang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 17 java.util Part 1: The Collections Framework . . . . . . . . . . . . . . . . . . . . 437 18 java.util Part 2: More Utility Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 19 Input/Output: Exploring java.io . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555 20 Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 21 The Applet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 22 Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 23 Introducing the AWT: Working with Windows, Graphics, and Text . . 663 24 Using AWT Controls, Layout Managers, and Menus . . . . . . . . . . . . 701 25 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 26 The Concurrency Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787 27 NIO, Regular Expressions, and Other Packages . . . . . . . . . . . . . . . . . 813 Software Development Using Java 28 Java Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847 29 Introducing Swing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859 30 Exploring Swing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879 31 Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907 Part IV Applying Java 32 Financial Applets and Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931 33 Creating a Download Manager in Java . . . . . . . . . . . . . . . . . . . . . . . . . 965 A Using Java’s Documentation Comments . . . . . . . . . . . . . . . . . . . . . . . 991 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997

Normalization,1NF,2NF,3NF, BCNF, with some of the brief examples which are in detail and helpful to know in detail about the concept(Bachelor of engineering)

Normalization,1NF,2NF,3NF, BCNF, with some of the brief examples which are in detail and helpful to know in detail about the concept.

Arrays in Java

An array is a container object that holds a fixed number of values of a single type. An item in an array is called an element. Every element can be accessed via an index. The first element in an array is addressed via the 0 index, the second via 1, etc.Try your Self:package com.vogella.javaintro.array;public class TestMain { public static void main(String[] args) { // declares an array of integers int[] array; // allocates memory for 10 integers array = new int[10]; // initialize values array[0] = 10; // initialize second element array[1] = 20; array[2] = 30; array[3] = 40; array[4] = 50; array[5] = 60; array[6] = 70; array[7] = 80; array[8] = 90; array[9] = 100; }}

Strings in Java

The String class represents character strings. All string literals, for example, "hello", are implemented as instances of this class. An instance of this class is an object. Strings are immutable, e.g., an assignment of a new value to aString object creates a new object.To concatenate Strings use a StringBuilder.Try Your Self:StringBuilder sb =new StringBuilder("Hello ");sb.append("Eclipse");String s = sb.toString();Avoid using StringBuffer and prefer StringBuilder. StringBuffer is synchronized and this is almost never useful, it is just slower.

Working With Strings

The following lists the most common string operations. Command Description"Testing".equals(text1);                Return true if text1 is equal to "Testing". The check is case-sensitive."Testing".equalsIgnoreCase(text1);       Return true if text1 is equal to "Testing". The check is not case-sensitive. For example, it would also be true for"testing".StringBuilder str1 = new StringBuilder();    Define a new StringBuilder which allows to efficiently add "Strings".str.charat(1);                  Return the character at position 1. (Note: strings are arrays of chars starting with 0)str.substring(1);                       Removes the first characters.str.substring(1, 5);          Gets the substring from the second to the fifth character.str.indexOf("Test")            Look for the String "Test" in String str. Returns the index of the first occurrence of the specified string.str.lastIndexOf("ing")                  Returns the index of the last occurrence of the specifiedString "ing" in the String str.str.endsWith("ing")            Returns true if str ends with String "ing"str.startsWith("Test")      Returns true if String str starts with String"Test".str.trim()                               Removes leading and trailing spaces.str.replace(str1, str2)                  Replaces all occurrences of str1 by str2str2.concat(str1);                         Concatenates str1 at the end of str2.str.toLowerCase() / str.toUpperCase()      Converts the string to lower- or uppercasestr1 + str2                                   Concatenate str1 and str2

Lambdas in Java

What is Lambdas?The Java programming language supports lambdas as of Java 8. A lambda expression is a block of code with parameters. Lambdas allows to specify a block of code which should be executed later. If a method expects afunctional interface as parameter it is possible to pass in the lambda expression instead.The type of a lambda expression in Java is a functional interface.Purpose of lambdas expressions.Using lambdas allows to use a condensed syntax compared to other Java programming constructs. For example theCollection interfaces has forEach method which accepts a lambda expression.List<String> list = Arrays.asList("vogella.com","google.com","heise.de" ) list.forEach(s-> System.out.println(s)); Using method references.You can use method references in a lambda expression. Method reference define the method to be called viaCalledFrom::method. CalledFrom can be * instance::instanceMethod * SomeClass::staticMethod * SomeClass::instanceMethodList<String> list = new ArrayList<>(); list.add("vogella.com"); list.add("google.com"); list.add("heise.de"); list.forEach(System.out::println); Difference between a lambda expression and a closure.The Java programming language supports lambdas but not closures. A lambda is an anonymous function, e.g., it can be defined as parameter. Closures are code fragments or code blocks which can be used without being a method or a class. This means that a closure can access variables not defined in its parameter list and that it can also be assigned to a variable.

Streams

What is streams?A stream from the java.util.stream package is a sequence of elements from a source that supports aggregate operations.IntstreamsAllow to create a stream of sequence of primitive int-valued elements supporting sequential and parallel aggregate operations.package com.vogella.java.streams; import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; public class IntStreamExample { public static void main(String[] args) { // printout the numbers from 1 to 100 IntStream.range(1, 101).forEach(s -> System.out.println(s)); // create a list of integers for 1 to 100 List<Integer> list = new ArrayList<>(); IntStream.range(1, 101).forEach(it -> list.add(it)); System.out.println("Size " + list.size()); } }

Reduction operations

Reduction operations with streams and lambdas.Allow to create a stream of sequence of primitive int-valued elements supporting sequential and parallel aggregate operations.Try your self:1St package com.vogella.java.streams;public class Task { private String summary; private int duration; public Task(String summary, int duration) { this.summary = summary; this.duration = duration; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public int getDuration() { return duration; } public void setDuration(int duration) { this.duration = duration; }}2nd:package com.vogella.java.streams;import java.util.ArrayList;import java.util.List;import java.util.Random;import java.util.stream.Collectors;import java.util.stream.IntStream;public class StreamTester { public static void main(String[] args) { Random random = new Random(); // Generate a list of random task List<Task> values = new ArrayList<>(); IntStream.range(1, 20).forEach(i -> values.add(new Task("Task" + random.nextInt(10), random.nextInt(10)))); // get a list of the distinct task summary field List<String> resultList = values.stream().filter( t -> t.getDuration() > 5).map( t -> t.getSummary()).distinct().collect(Collectors.toList()); System.out.println(resultList); // get a concatenated string of Task with a duration longer than 5 hours String collect = values.stream().filter( t -> t.getDuration() > 5).map( t -> t.getSummary()).distinct().collect(Collectors.joining("-")); System.out.println(collect); }}