Tuesday, July 30, 2019

HTML - Adding Google Maps to Web Page - API Example

1.Overview


In this tutorial, We'll learn how to add Goole Maps to your website or page.

This is very easy to understand adding Google maps to the web page.

To make maps available on a web page, we must include the google maps API using the below script.

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&callback=myMap"></script>

You have to register and get the key from https://cloud.google.com/maps-platform/. Without the key, maps can not be loaded.

Thursday, July 11, 2019

Java 8 - Working with IntSupplier

1. Overview


In this tutorial, We'll learn how to use IntSupplier Functional Interface and part of package java.util.function which has been introduced in java 8.

IntSupplier represents a supplier of int-valued results. This is the int-producing primitive specialization of Supplier.

As we discussed in the previous article on "Working with Supplier Functional Interface", IntSupplier comes under Supplier's category and does not take any argument.

IntSupplier has only one functional method that is getAsInt().

Java 8 - Working with IntSupplier


When we expect an int primitive value rather than Integer wrapper then we should not use directly Supplier FI. Because it does autoboxing and leads to performance issues.

Wednesday, July 10, 2019

Java 8 Functional Interfaces (FI)

1. Overview

In this tutorial, We'll learn about Functional Interface added to Java 8. Functional Interface is abbreviated as FI.

These Functional Interfaces are used extensively in Lambda Expressions.

Please read article on "A Complete Guide to Lambda Expressions"

If you have a basic understanding of Lambda's that will help in using Functional Interface(FI) properly. But, We will discuss in short about Lambda's.

Java 8 Functional Interfaces (FI)


We will cover the following concepts in this article.


  • Intro to Lambda
  • Lambda Examples
  • Functional Interface Definition
  • @FunctionalInterface annotation
  • Built-in FI's
  • Types of Functional Interfaces with examples


Wednesday, July 3, 2019

[Fixed] Error: Could not find or load main class

1. Overview


In this tutorial, We'll learn What does "Could not find or load main class" mean?

A common problem that new Java developers experience is that their programs fail to run with the error message: Could not find or load main class.

What does this mean, what causes it, and how should you fix it?

The problem is with this java run command

java  command syntax

We have gathered all these solutions from StackOverflow page and arranged in a simple manner to understand easily.

[Fixed] Error: Could not find or load main class


Please read section 2 and 5 to get a clear understanding. Section 3 tells about all areas where we do mistake usually. But, recommend reading the complete article.

Tuesday, July 2, 2019

Java 8: Working with Supplier

1. Overview

In this tutorial, We'll learn about java 8 Supplier Functional Interface.

Supplier is part of package java.util.function. This is introduced in Java 8 as part of Function programming.

Api Reference

Supplier Functional Interface has only one Abstract method.


T get()

Where T -  the type of results supplied by this supplier

Java 8 - Working with Supplier


This method is called as Functional Method.

Supplier does not take any argument but returns a value always. Because of this named as Supplier as supplies everytime something when we call get() method.

Suppliers are very useful when we do not need to supply any value but need to return a value at the same time.

Monday, July 1, 2019

Java 8: Accessing Variables from Lambda Expressions

1. Overview

In this tutorial, We'll learn about how to access variables from Lambda Expressions in Java 8.

Before that, We suggest you read the tutorial on Java 8 Lambda Expressions discussed in the previous tutorial.

If you already know about Lambda's, just ignore and continue reading this article.

Can we declare a variable inside Lambda Expression?

Java 8: Accessing Variables from Lambda Expressions


The answer is yes. We can declare variables as many as needed.

What do you think if lambda has a reference to another variable?

Here, We have two scenarios to know.

First, What will happen for local variables in Lambda.

Second, Non-local variables to Lambda.