Primitive Data Types

Primitive Data Types in Java

The 8 primitive data types byte, short, int, long, char, boolean, float, and double are the types that store most raw numerical data in Java programs. The char primitive data types A char can store a single 16-bit Unicode character. A character literal is enclosed in single quotes char myChar = ‘u’;char myChar2 = ‘5’;char … Read more

Date class in Java

Date Class in Java

The Date class of java. util package implements Serializable, Cloneable, and Comparable interface. It provides constructors and methods to deal with date and time with java. Date(): Creates date object representing the current java date and time. Parameter Explanation No parameter Creates a new Date object using the allocation time (to the nearest millisecond) long date Creates a new Date object with the time set to … Read more

Literals in Java

Literals in Java

Java is an Object-Oriented Program. Literals are a representation of a fixed value by source code. They ‘re explicitly interpreted without any computation in the code. Every primitive form variable can be assigned literal. Java literal is a syntactic element (i.e. something you find in the source code of a Java program) that represents a … Read more

String Tokenizer

String Tokenizer in Java

The java.util.StringTokenizer class allows you to break a string into tokens. It is simple way to break string. The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a pertoken basis. StringTokenizer Split by space import java.util.StringTokenizer; public class Simple{ public static void main(String args[]){ StringTokenizer st … Read more

Strings in Java

Strings in Java

Strings (java.lang.String) are pieces of text stored in your program. Strings are not a primitive data type in Java, however, they are very common in Java programs. In Java, Strings are immutable, meaning that they cannot be changed. (Click here for a more thorough explanation of immutability.) Comparing Strings In order to compare Strings for … Read more

Java Data Types

Data Types in Java

There are two types of java data types: Primitive data types: The primitive java data types include boolean, char, byte, short, int, long, float, and double. Non-primitive java data types: The non-primitive java data types include Classes, Interfaces, and Arrays. The Double Primitive Java Data Type A double is a double-precision 64-bit IEEE 754 floating point number. double example = -7162.37; double myDouble = 974.21; … Read more

String pool and heap storage

String pool and heap storage

String is a sequence of characters, for e.g. “Hello” is a string of 5 characters. In java, string is an immutable object which means it is constant and can cannot be changed once it has been created. Finding a String Within Another String To check whether a particular String a is being contained in a … Read more

Java Language – Case insensitive switch

Case Insensitive Switch in Java

Case insensitive switch Version ≥ Java SE 7 switch itself can not be parameterized to be case insensitive, but if absolutely required, can behave insensitively to the input string by using toLowerCase() or toUpperCase: switch (myString.toLowerCase()) { case “case1” : … break; case “case2” : … break;} Beware Locale might affect how changing cases happen! … Read more

How To Split Strings in Java

Split Strings in Java

The string split() method in Java splits a given string around matches of the given regular expression. Example Java StringTokenizer, and String Split. The StringTokenizer class allows us to break a string into tokens in an application. This class is a legacy class retained for purposes of consistency although its use is discouraged in new … Read more

Substrings in Java

Substrings in Java

A segment of the string is called substring. To put it another way, substring is a subset of another string. StartIndex is inclusive and endIndex is exclusive when substring. Substrings String s = “this is an example”; String a = s.substring(11); // a will hold the string starting at character 11 until the end (“example”) … Read more

StringBuffer and StringBuilder Classes in Java

StringBuffer and StringBuilder Classes in Java

Introduction to Java StringBuffer class. In Java StringBuffer class. StringBuffer is a peer string class that provides much of the string functionality. String represents fixed-length, immutable sequences of characters while StringBuffer represents growable, writable sequences of characters. StringBuffer class Key Points: used to created mutable (modifiable) string. Mutable: Which can be changed. is thread-safe i.e. … Read more

JavaScript Variables

Variables in JavaScript

JavaScript Variables Tutorial from Coding compiler. Depending on what you are doing the script, you will need to work with the information. If this is an electronic store, then this is a goods basket. If the chat – visitors, messages and so on.

Variables are used to store information .

Read more