The java.lang.Math class contains many static method for performing various math related functions. One useful utility is the Round() method, which is used to round a float or double number to the closest whole number representation. This post will give explain and give examples on how to use the Java Math.Round() method.
No matter how advanced programming will be in the future, the basics will always be important. Cornerstone are basic data structure such as String Array, which is very simple to understand and use. One typical thing we wish to do with a String Array is to loop through all of it's values. Below is an example on how to loop to all values of a String Array, using for loop introduced in Java 5.
It is a common scenario that we need to manipulate multiple String values. String Array is always a good choice because it is very simple to work with. The first thing we wish to do when working with arrays is to initialize it with values. We will share below some code examples on how to initialize a String Array in Java.
String Array is a very useful data structure when we need to hold multiple String values. It is very simple to understand for programmers with background in some other language. It is also easy to use for many programming scenarios. But one common thing we usually need when working with Arrays, is that we sometimes need the data to be ordered or sorted. Below are some examples on how to Sort String Array in Java.
Arrays are very useful when we need to work with multiple values of the same type. For example, we may need multiple instances of Strings. Arrays provide a data structure that is easy to learn and use. But since arrays are simple, it does not have much methods for some operations we may need. Below are examples on how to test or check if a String Array contains a certain value in Java.
Working with arrays in Java is common because this data structure is simple to use and very efficient. Most programming language supports arrays, so many developers may have idea on how to use it without reading much documentation. Specially for programmers coming from C or C++ background, the way on how to use it is very similar. But there is one big limitation when working with Arrays in Java, the length or size of Arrays are fixed. Meaning we can not increase or decrease the size without programming tricks. Below are some examples on how we can add element to a String Array in Java.
One-dimensional arrays in Java are commonly used in everyday programming. However, there are instances where we need two-dimensional array. An example is holding data for a table listing with multiple columns and rows. Another example is holding information about a board game like chess. Below are some example on how to work with Two Dimensional String Array in Java.
A String Array is a data structure that holds several String values. The number of String elements is fixed and can't be changed throughout the lifetime of the array object. One common thing that we wish to do with String Array is to go through all the data it contains and process individually. Below contains examples on how to iterate through String Array in Java.
String Array is a commonly used data structure when programming in Java. Although we can generally use List for greater flexibility, but sometimes using String Array is more suitable for a given scenario. Arrays in general have the property of having fixed number of elements and the size can't be changed throughout the lifetime of the data structure. When given a String Array as parameter to our method, it is common that we wish to know the length of it. Below are some examples on how to get the length of a String Array in Java.
There are programming scenarios where we have a data in byte array that represents a String. This could be a case when we use a third party library to load data somewhere and the result is a byte array. In such cases, we may want to convert back the byte array to a String. Below are some examples on how to convert a byte array to String in Java.