Tag: guide
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.
Downloading and Installing AngularJS via CDN
If you want to use AngularJS in your webpage , you just need to point the <script> tag in the page to the AngularJS file. You can either download the AngularJS script file to your project and use it from there or use CDN (Content Delivery Network). How to download and install AngularJS via CDN ? You just need to add the below script within…
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…
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.
Java – How to check if a double value is Infinite ?
Problem Statement You need to find out if the given number of type double is Infinite or not. Solution Use the isInfinite method defined in the Double class to find of the given number is a infinite as shown below. The output of the above program is Abundantcode.com Java Tutorials true
Java – How to Convert Long to String in Java ?
Problem Statement You need to convert long to a string value in your java program. Solution Use the toString method to convert long to string in Java. The output for the above program is Abundantcode.com Java Tutorials 75
ElasticSearch – How to Interact with ElasticSearch using JSON over HTTP ?
Problem Statement You need to communicate with ElasticSearch to perform the search or the CRUD operations. Solution You can interact with ElasticSearch using the RESTful API over port 9200. Additionally , ElasticSearch has the official clients for various programming languages like .NET , Java , Ruby etc. The format of the request of ElasticSearch is as specified below. <VERB> <PROTOCOL> ://<HOST>/<PATH>?<QUERYSTRING> Additionally , it can…
Java – How to Convert Numbers to Objects and vice versa ?
Problem Statement You need convert numbers to objects and vice versa in your Java program. Solution There are times when you need to pass an object for a function where you have a numeric values. To convert numbers to objects and vice versa , you can use the corresponsing wrapper classes. For example , if you want to convert an int to Integer object or…
SQL Server 2014 Tutorial – Assign TCP/IP Port to Database Engine
Problem Statement You need to change the SQL Server 2014 port number from 1433 to a different port number. Solution By default , SQL Server runs on the port number 1433. You can change it to different port number by following the below steps. 1. Open SQL Server 2014 Configuration Manager from the Windows Start menu. 2. In the left side bar of the Sql…
Java – How to use Packages to organize code ?
Problem Statement You need to use packages in java to organize your code. Solution Your Java program might the following Classes Interfaces Enums Other types There are times when your program might grow larger including th number of java classes used. You might want to organize these source files to that it is easier to maintain and avoid other issues like class name conflicts. Inorder…
Java – How to round floating point number to integer ?
Problem Statement You need to round the floating-point numbers to integers in Java. Solution When you cast a floating value to integer in Java , the value gets truncated. For example , the value 7.8989 when casted to integer will become 7. In order to round he floating-point numbers correctly , you can use the Math.round() method. The Math.round method has a 2 overloaded forms….
Java – How to decode string from Hexadecimal and Octal to Integer in Java ?
Problem Statement You need to decode a string from hexadecimal to integer in java as well as octal to integer. Solution Use the decode method defined in the Integer class to decode an hexadecimal and octal number to integer as shown below. The output of the above program is 255 46
Java – How to Check if integer is multiple of a number?
Problem Statement You need to check if the integer number is a multiple of a number in Java. Solution Use the modulus operator and check the remainder to find it out. Below is a sample code snippet demonstrating how to find if the number is a multiple of 4.
How to Declare an Octal literal in Java ?
Problem Statement You want to declare an octal literal in Java. Solution Prefix the value with 0. A literal that contains leading zero is an octal number. The output of the above program will be 8 21
Json.NET & Oxygene – How to Serialize a Collection?
Do you want to serialize an collection in your Remobjects Oxygene.NET application?. Json.NET supports this functionality with ease. The Collection can be an Array , Dictionary or List. You need to simply pass collection to the JsonConvert.SerializeObject static method which would serialize the collection and return you the Json string. How to Serialize a Collection in Oxygene.NET using Json.NET library ? For example , assume…
SQL Server 2014 Tutorial – Open SQL Server Instance Port in Windows Firewall
Problem Statement You need open the SQL Server Instance port number in Windows Firewall so that you can connect to SQL Server from another machine. Solution When you try to connect to the SQL Server instance from another machine , you might receive the connection timeout error . To allow the users of other machine to connect to your SQL Server instance , you need…
Java – How to get the String representation of the Boolean value in Java ?
Problem statement You need to convert the Boolean value to string and display the string representation of the same. Solution Use the toString static method defined in the Boolean class for the conversion. The output of the above program is Abundantcode.com Java Tutorials false