Learn Java Programming

Java Basics

How to use Bitwise Operator in Java

The java Binary Operators such as Bitwise Shift Operator, Bitwise Complement Operator and Unsigned Right Shift Operators that performs the bit level manipulation. The Binary operators such as AND, OR, NOT, XOR are performed using the Bitwise Operators in java. Java Bitwise operators manipulate individual bits of a number. Bitwise

Switch Case Java

The Java switch case statement checks a variable with multiple values. The switch case in java matches the given value from multiple values and executes the corresponding switch statement. Java Switch contains multiple cases. Each switch case contains a block of code. The Switch case statement in java is a

Ternary Operator Vs If Else

The java ternary operator or conditional operator is supported in languages such as java, javascript, python, c / c++, c# etc. The java ternary operator or conditional operator takes three operands, one condition followed by a question mark (?), then an expression to be executed if the condition is true

Thread Synchronization in Java

Java Thread Synchronization is a way of synchronising Java threads to access a shared resource in a controlled way. If multiple threads attempt to access a shared resource, due to concurrency problems, they may create unintended outcomes . Java threads are synchronised to prevent unpredictable outcomes. There will be only

Java program to write into a text file

There are several ways to write to a Java text file. Java supports different types of api to write file content. For example, write character by character, write line by line or write byte by by byte. Write to text file in Java In this post, we explained five types

Java Bean Standard, Specification, Properties, Requirements

A Java Bean is a java class that should follow the java bean standards and requirements. If a java class meets the java bean specification, the java class is called as java bean. The java bean has some properties and characteristics. A JavaBean is a java class which should follow

String index out of range

In Java, “String index out of range” exception is thrown in java substring() & charAt() method. Here, we see the exception “java.lang.StringIndexOutOfBoundsException: String index out of range: 0“. If a invalid value is passed in begin and end index value, “java.lang.StringIndexOutOfBoundsException: String index out of range” will be thrown. The

java.lang.StringIndexOutOfBoundsException: String index out of range

The java.lang.StringIndexOutOfBoundsException: String index out of range arises when the string index is either negative, or larger than the length of the string, i.e. out of range The java string index range should be in between 0 and the size of the string. The java String.charAt() method returns the character

java.io.UnsupportedEncodingException example

The java.io.UnsupportedEncodingException occurs when an unsupported character encoding scheme is used in java strings or bytes. The java String getBytes method converts the requested string to bytes in the specified encoding format. If the java does not support the encoding format, the method String getBytes throws java.io.UnsupportedEncodingException with the encoding

How to resolve java.util.regex.PatternSyntaxException at String.matches, String.split, String.replaceAll

The java.util.regex.PatternSyntaxException is thrown when the regular expression – regex pattern is not correct. The java String matches method checks the given string with the specified regular expression. If the java string matches the regular expression, it will return true, otherwise it will return false. The java exception java.util.regex.PatternSyntaxException is