Generate SSH keys
- ssh-keygen -b 4096 -t rsa
Java is widely used staticly typed programming language which is founded over 25 years back. It's almost everywhere from home appliances, mobile devices to industry scale systems. Java is evolving over the time and from Java 8 onwards there were major changes introduced to the language. Below are the list of all the changes on each version.
Imperative approach is defining step by step on HOW we are going to achieve the end result. Declarative approach is describing WHAT we want as the output.
Simple example would be a classical for loop in Java which we can call as imperative programming and a select query in sql as declarative programming.
Still didn't get it? Following examples will help you to understand more
A lambda expression is an anonymous function. It's a function without a name and does not belong to any class
Lambda vs java method
method in Java has three main parts
-Name
-Parameter List
-Body
-return type
lambda expression in Java has three main parts
-No name (since lambda is anonymous function)
-Parameter List
-Body
-No return type (no return type required)
List list = new ArrayList();
list.add(1000); //works fine
list.add("Gothama"); //run time error;
List<Integer> list = new ArrayList<Integer>();
list.add(1000); //works fine
list.add("Gothama"); //compile time error;
public class GenericsMethodTest{
public static void main(String args[]) {
// Create arrays of Integer, Double and Character
Integer[] intArray = { 1, 2, 3, 4, 5 };
Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4 };
Character[] charArray = { 'H', 'E', 'L', 'L', 'O' };
System.out.println("Array integerArray contains:");
printArray(intArray); // pass an Integer array
System.out.println("\nArray doubleArray contains:");
printArray(doubleArray); // pass a Double array
System.out.println("\nArray characterArray contains:");
printArray(charArray); // pass a Character array
}
// generic method printArray
public static < E > void printArray( E[] inputArray ) {
// Display array elements
for(E element : inputArray) {
System.out.printf("%s ", element);
}
System.out.println();
}
}
Output:
Array integerArray contains:
1 2 3 4 5
Array doubleArray contains:
1.1 2.2 3.3 4.4
Array characterArray contains:
H E L L O
public class Box<T> {
private T t;
public void add(T t) {
this.t = t;
}
public T get() {
return t;
}
public static void main(String[] args) {
Box<Integer> integerBox = new Box<Integer>();
Box<String> stringBox = new Box<String>();
integerBox.add(new Integer(10));
stringBox.add(new String("Hello World"));
System.out.printf("Integer Value :%d\n\n", integerBox.get());
System.out.printf("String Value :%s\n", stringBox.get());
}
}
Output:
Integer Value :10
String Value :Hello World
public class DemoClass
{
//some code
@Override
public String toString()
{
return super.toString();
}
@Override
public int hashCode()
{
return super.hashCode();
}
}
public @interface DemoAnnotation {}
@DemoAnnotation
public void toggle() {}
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Lazy {
/**
* Whether lazy initialization should occur.
*/
boolean value() default true;
}
@Lazy
class VehicleFactoryConfig {
@Lazy(false)
Engine engine() {
return new Engine();
}
}
// Java program to illustrate the concept
// of Autoboxing and Unboxing
import java.io.*;
class Independor
{
public static void main (String[] args)
{
// creating an Integer Object (wrapper class of int)
// with value 10.
Integer i = new Integer(10);
// unboxing the Object
int i1 = i;
System.out.println("Value of i: " + i);
System.out.println("Value of i1: " + i1);
//Autoboxing of char
Character gfg = 'a';
// Auto-unboxing of Character (wrapper class of char)
char ch = gfg;
System.out.println("Value of ch: " + ch);
System.out.println("Value of gfg: " + gfg);
}
}
September, 2017
. The biggest change is the modularization i.e. Java modules.March 18, 2014
July 28, 2011
December 11, 2006
September 30, 2004
for each
loopjava.util.concurrent
Scanner
class for parsing data from various input streams and buffers.February 6, 2002
assert
keywordMay 8, 2000
December 8, 1998
strictfp
keywordJanuary 23, 1996
SFTP is the secured method of implementing FTP where you can use a server or storage location as FTP location which you can transfer files f...