Category: Java
Microsoft Band and Android(Java) -Get the Version Information
Below is a sample code snippet demonstrating how to get the version information from Microsoft Band using Java from android app. How to Get Microsoft Band Version Information using Java in Android Application ?
Java – How to convert a bool or string value to Boolean in Java ?
Problem Statement You need to convert a boolean value of string value to Boolean type in your java program. Solution Use the Boolean class’s constructor and pass the corresponsing parameter to change it. Below is the sample code snippet demonstrating how to do it. The output of the above program is Abundantcode.com Java Tutorials false false
Java – How to Divide BigDecimal value from another in Java ?
Problem Statement You want to divide one BigDecimal value from another in your Java program. Solution Use the divide() instance method defined in the BigDecimal class as shown below.
Java How to – Find if the Class exists or not
Problem Statement You need to test for the presence of a class from your java program. Solution Use Class.forName method to find if a particular class exists. Below is a sample code snippet demonstrating the usage of Class.forName to find out if the class “test” exists. Note that this method throws an exception incase the class cannot be loaded. Note: You need to pass the…
Keywords in Java
Below are some of the well known keywords in Java Keywords in Java abstractassertbooleanbreakbytecasecatchcharclassconstcontinuedefaultdodoubleelseenumextendsfinalfinallyfloatforgotoifimplementsimportinstanceofintinterfacelongnativenewpackageprivateprotectedpublicreturnshortstaticstrictfpsuperswitchsynchronizedthisthrowthrowstransienttryvoidvolatilewhile
Mocking frameworks for Java Developers
There are plenty of mocking framework for java that are available for developers. Below are some of the links or collections of mocking frameworks for Java Developers Mocking frameworks for Java Developers PowerMock JtestR EasyMock Mockito jmockit
Java Program #3
What is the output of the following Java program? Output false, true, false The iterator() method returns an iterator over the elements in the list in sequential order. It doesn’t return a List or a ListIterator object. You can get a ListIterator object by invoking the listIterator method.
Tools to Convert Java to C# Source Code
There are times when a developer would have done a project using Java and would want to reuse some of the data classes or business logic to C# for developing application on different platform. Tools to Convert Java to C# Source Code Below are some of the tools that can be used to convert the code from Java to C# . Sharpen This is a…
Java – How to Check if a string is a valid number?
Problem statement You need to check if a input string contain a valid number or not. Solution Use the appropriate wrapper class for converting the string to numeric formats. For example Double to convert string to double as shown below. When the input is a invalid number , the NumberFormatException is caused which needs to be handled by the developers.
Java – How to parse a string to Boolean object in Java ?
Problem Statement You need to parse the string value to the Boolean object in your Java program. Solution Use the valueOf static method defined in the Boolean class to parse the string value and convert it to the Boolean object in Java.
Java – How to create a random number which is less than 25 ?
Problem Statement You need to create a random number which is less than 25 in Java. Solution Use the Random class’s nextInt method and pass the value within which the random number needs to be generated.
How to sort an array using Comparator in Java ?
The Arrays.sort method in java lets the developers to sort an array of objects. The sort method also accepts the comparator object which can contain the sorting logic. How to sort an array using Comparator in Java ? Below is a sample code snippet demonstrating the usage of the Arrays.sort method with the comparator.