Dec 11

Java example to convert String to Boolean in java?

Number of View: 32

 

Dec 10

How to convert String to BigDecimal in java?

Number of View: 46

To convert String to BigDecimal in java use BigDecimal Constructor.The below example demonstrates how to convert String to BigDecimal in java.

 

Output :

Printing BigDecimal Value 100.00

Nov 15

Java Glossary/ Dictionary-Letter C-part 8

Number of View: 112

37) Collections :

Collections class contains several static methods and constants which are useful for working with collections.Collections defines several algorithms which can be applied to collection objects.

Collections contains several static methods. Continue reading

Nov 15

Java Glossary/ Dictionary-Letter C-part 7

Number of View: 77

31) ClassLoaders :

Class loaders in java are used to load classes at runtime.

There are 3 different class loaders in java :

  1. Bootstrap class loader
  2. Extension class loader
  3. System class loader.

32) Class method :

Class methods are also called as static methods.

Static members are used by other classes without creating an instance of the class.

Static methods do not operate on objects.

Methods are declared as static when they perform operations independent of instance variables.

Static method belongs to whole class not to particular instance.

Static method operate only on static data and cannot access non static data such as instance variables.

A static method can call other static method but cannot call non static methods.

A static method cannot refer to super or this keyword.

Example : Math class which contains only static fields and methods.

To call static method use class name followed by dot.

Syntax:ClassName.methodName(argument);

Ex:Math.sqrt(16);

Note : JDK 8 added a new feature static methods can be defined in interface.Just like how we call static methods in class in the same way we call static methods in interface. Continue reading

Nov 15

Java Glossary/ Dictionary-Letter C-part 6

Number of View: 83

26) Cast :

Casting is used to convert one datatype in to another.We can use casting to convert double to int.In casting there is a chance to lose information.

For example : when converting double to int.

 

27) Catch :

Catch block is used to catch the exception.Catch block gets executed whenever an exception is thrown.Each catch block is an exception handler that handles the exception indicated by its argument.

Prior to java 7 catch block can handle only type of exception.From Java 7 a catch block can handle more than one type of exception.

Catch blocks are associated with try blocks.For every try block there should be atleast one catch block or finally block. Continue reading