Home » Java Basics (page 3)

Java Basics

Java 8 Lambda Expressions Tutorial

In this article we are going to explain what Lambdas are, why are they important and how do they look like in Java. We are going to see also a couple of examples and real life applications. All examples are being implemented using Eclipse Luna version 4.4 and Java version 8 update 5. Lambdas? A Lambda, in general, is a ...

Read More »

java.util.NoSuchElementException – How to solve NoSuchElementException

In this tutorial we will discuss about NoSuchElementException in Java. This exception is thrown to indicate that there are no more elements in an enumeration. This exception extends the RuntimeException class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM). It is an unchecked exception and thus, it does not ...

Read More »

java.io.NotSerializableException – How to solve Not Serializable Exception

In this tutorial we will discuss about NotSerializableException in Java. The exception is thrown when an instance of a class must implement the Serializable interface. The exception is thrown by either the serialization runtime, or by the instance of the class. The argument of the NotSerializableException is the name of the class. The NotSerializableException class extends the ObjectStreamException class, which ...

Read More »

Java String to Date Example

Java gives us the capability to convert String to Date. This can be done through DateFormat and SimpleDateFormat classes, where the last class is a subclass of the first one. It is worth to mention that DateFormat is not thread-safe, so it is recommended to create different instances for each thread. In this example we will show you how to ...

Read More »

Java String to char Example

String to char conversion is a very simple procedure in Java. This process is useful when we want to use char format instead of strings in our applications, for instance in the arguments in command line. In this example we are going to show you how to parse a String to character(s). 1. Example of String to char conversion Create ...

Read More »

Java String to Float Example

float is a frequently used data type of 32-bit and it represents decimal numbers. The main difference from double is that it requires smaller size in memory but in some situations (big numbers) doesn’t represent the accurate number. A commonly used procedure in Java is the convertion from string to float. In this example we shall show you all the ...

Read More »

Java static class Example

In this example, we will discuss about static classes in Java. First of all, let’s give a short explanation of the static modifier. For example, if a field or a method in a class has the static modifier in its declaration , then it is always associated with the class as a whole, rather than with any object of the ...

Read More »

Java string to long Example

Long class forms the primitive type long, which can represent an integer number of 32 bits (2^32). A very common procedure in Java programming is the conversion of String to Long. As you can expect, in this example we are going to show how to convert a string to long in every possible way.         1. Syntax ...

Read More »