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

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 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

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….

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…