
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7442 Articles for Java

553 Views
There are different scoping rules for lambda expression in Java. In lambda expressions, this and super keywords are lexically scoped means that this keyword refers to the object of the enclosing type and the super keyword refers to the enclosing superclass. In the case of an anonymous class, they are relative to the anonymous class itself. Similarly, local variables declared in lambda expression conflicts with variables declared in the enclosing class. In the case of an anonymous class, they are allowed to shadow variables in the enclosing class.Example@FunctionalInterface interface TestInterface { int calculate(int x, int y); } class Test { public ... Read More

4K+ Views
The lambda expressions are easy and contain three parts like parameters (method arguments), arrow operator (->) and expressions (method body). The lambda expressions can be categorized into three types: no parameter lambda expressions, single parameter lambda expressions and multiple parameters lambda expressions.Lambda Expression with no parameterWe need to create no parameter lambda expression then start the expression with empty parenthesis.Syntax() -> { //Body of no parameter lambda }Example(no parameter Lambda)import java.util.function.*; import java.util.Random; public class LambdaExpression1 { public static void main(String args[]) { NumberUtil num = new NumberUtil(); int randVal = num.getRandomValue( ... Read More

1K+ Views
A lambda block states that lambda expression with multiple statements. It expands the type of operations to perform with a lambda expression. The multiple statements containing bodies are called expression bodies. A lambda expression with expression bodies is called expression lambdas. Whenever we are using expression lambdas, explicitly use a return statement to return a value.Exampleinterface NumberFinder { int finder(int number1, int number2); } public class LambdaNumberFinder { public static void main(String args[]) { NumberFinder numberFinder = (number1, number2) -> { int temp = 0; if(number1 > number2) ... Read More

816 Views
The lambda expressions are anonymous functions and don't have any return type, access modifier and not belonging to any class. It can be used to simplify the implementation of the abstract method in a functional interface. Whenever there is a functional interface, we can use lambda expressions instead of anonymous inner classes.Syntax([comma seperated argument-list]) -> {body}Example@FunctionalInterface interface BonusCalculator { public double calcBonus(int amount); } class EmpDetails { public void getBonus(BonusCalculator calculator, int amount) { double bonus = calculator.calcBonus(amount); System.out.println("Bonus: " + bonus); } } public class LambdaExpressionTest { public static void main(String[] ... Read More

1K+ Views
The lambda expressions have a very simple, precise syntax and provide flexibility to specify the datatypes for the function parameters. Its return type is a parameter -> expression body to understand the syntax, we can divide it into three parts.Parameters : These are function method parameters and match with the signature of a function defined in the functional interface. Defining the data-type of parameters is optional but the number of parameters can match with the defined signatures in the interface.Expression Body : This is either a single statement or collection of statements that represent the function definition. Defining the data-type for return ... Read More

444 Views
Both Go and Java are popular backend programming languages, and each has its own unique features. Java is an older language with a large community support, whereas Go is a comparatively newer language developed by Google. In this article, we will learn more about the differences between Go and Java. Go Language Go, also called Golang, is an open-source programming language developed by Robert Griesemer, Rob Pike, and Ken Thompson at Google. It was created to build large and complex software systems more easily. It is a statically typed and compiled programming language that has a simple and ... Read More

8K+ Views
AssociationAssociation in terms of objects refers to "has a" relationship between two related objects. For example, a employee has a communication address.class Employee { String name; Address communicationAddress; } class Address { String address; }AggregationAggregation in terms of objects refers to "has a"+ relationship between two related objects. For example, a department has multiple employees. It refers to having a collection of child objects in parent class. For example:class Department { String name; List employees; } class Employee { String name; }Sr. No.KeyAssociationAggregation1DefinitionAssociation refers to "has a" relationship between two classes which use each ... Read More

1K+ Views
All of these functions are used to get character from input and each function returns an integer signifying the status code as well.Following are the important differences between getc(), getchar(), getch() and getche() functions.getc()getc() can read characters from any stream. Returns EOF on failure.Syntaxint getc(FILE *stream);getchar()getchar() can read characters from standard input only.Syntaxint getchar();getch()getch() can read characters from standard input but it does not use any buffer and returns immidately without waiting for enter key pressed.Syntaxint getch();getche()getche() behaves similar to getch() as it can read characters from standard input and it does not use any buffer and returns immidately without ... Read More

25K+ Views
Class A class is a blueprint from which individual objects are created. A class can contain any of the following variable types. Local Variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. Instance Variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. Class Variables − Class variables are variables declared ... Read More

21K+ Views
Constructors are special methods used to initialize objects, whereas methods are used to execute certain statements. Constructors and methods are both blocks of code inside a class, but they have different purposes. In this article we will learn about the main differences between a constructor and a method. What is a Constructor in Java? A constructor is a special method in Java that is automatically called when an object is instantiated. Constructors have the same name as the class and do not have a return type. Its main purpose is to set initial values to the newly created object. ... Read More