How to find String length in java string method

Get String length with String length() method To find String length in java there is a method length(). This method is used to get the length of the string. The signature of length method is:

The length method returns the length of the string. it counts the number of Unicode in string. str.length java … Read more

User Defined exception in Java | Java custom exception examples

In Java programming, it is possible to create our own exceptions and such exception are called user-defined exceptions in Java. The exception class is a predefined class. Any user-defined exception created by us must be a subclass of the predefined Exception class and created by extending the Exception class. Read More Exception Handling in Java: … Read more

Employee details program in java using class and object

Employee details program in java as below. Here two classes are created Employee class EmployeeMain class Details of these two classes are as below java program for employee details using class and object employee class in java : This class contains various fields of employees like id, fname, lname, address etc. Its corresponding getter … Read more

Prime number program in java using while loop

Here we generate and check prime number using while loop in java so that we titled this prime number program in java using while loop. 1 What is a Prime Number A prime number is a whole number that has only two factors 1 and the number itself. For example, 23 is a prime number, … Read more

Byte Streams in Java

In java programming, to perform input and output of 8-bit, Byte stream is used. Most common byte streams classes are, FileInputStream and FileOutputStream. FileInputStream : FileInputStream is used for reads one byte at a time . FileOutputStream : FileOutputStream is used for writes one byte at a time Writing Bytes Example: Write a program, to write a bytes to … Read more

Inheritance in Java-Types and Examples

Inheritance in Java is the process of acquiring the properties of one class object into another class object. It allows the hierarchical classification. Inheritance also provides the facility of reusability. In Java programming, a class that is inherited is called a superclass or sub class or parent class and class that does the inheriting is … Read more

Concatenate & Buffer File in Java

Here we will concatenating and store buffering files in java using BufferedInputClass and BufferedOutputClass. Concatenate: It is possible to concatenate two or more files and save in a different file. In java, by using SequenceInputStream class we can concatenate two or more files. Buffer Files: In java, we can create a buffer to store temporary … Read more

Simple Calculator in Java Applet

Java Applet provides a GUI way to create a program and its interface, Here we are creating Simple Calculator in Java Applet with GUI and its processing. As we have already learned about applet and applet life cycle. Here we have discussed two simple calculator programs using the applet. Simple applet- a beginner program Simple … Read more

Method Overloading with examples in Java

what is method overloading in java? In Java programming, Defining two or more methods with the same name with different parameter list are called Method Overloading in Java. Like void add(int a,int b);void add(double a, double b);void add(String a,String b);int add(int a,int b,int c); In method overloading, the method return type may be different. The … Read more

Gson parse json array with example

Gson parses JSON array meaning to Parsing JSON array with Google Gson library. Follow these steps to read JSON Array Create GSON Object Read array with fromJson() To read jsonString as an array we use the following syntax Gson gson=new Gson(); ElementType [] refVar=gson.fromJson(jsonString,ElementType[].class); To read jsonString as List TypeToken is used to find the … Read more