while loop random number Java

So in this post we try to do a simple loop that display some random Numbers. See example below:

Armstrong number in Java using for loop

It is a very good exercise to improve our logic and we wish to solve some problems. And so in this post we try to give example on how to solve this problem, determining Armstrong number in Java using for loop.

Java print even numbers while loop

We try to solve specific logical problems in Java using some form of loops. In this post we present an example on how to print even numbers using while loop in Java

Java Random Int

Generating random numbers is typically important in some applications that we do. For example, if we are writing a program that needs to shuffle a deck of cards, we can achieve that by swapping cards from random positions. In fact, many games requires random number generation because that makes each play unique from the previous one. Because if there is no randomness, then every time we play will feel the same. So below we try to show examples on how to generate Java Random Int values.

Java Char To String

A Java character is a primitive data type where it can only hold just 1 character value, whereas a String can contain multiple characters. A String represents a sequence of characters, while a char only contains a single character. For example, we can only assign the value 'A' to a char, and if we want to add more characters, we then need a String to do that. For example "AB" can't be stored using a char, but a String can. But sometimes, coming from a character, we wish to convert it into a String with only one char item inside. Below we explore some methods and examples on how to convert a Char To String in Java programming language.

Groovy String drop() examples

While exploring groovy langauge, I noticed two String methods take and drop. Both provide ways to get substring of a String. In this post, we discuss Groovy String drop method and ow to use it.

Groovy String reverse() examples

Groovy is fun to use because it gives utility methods out of the box without us requiring any special external library, and without needing to write out own code. Mostly are simple and very intuitive. We explore one method in this example. In this post, we will check how to use Groovy String reverse method.

Java String Trim

We always love working with Strings in our own programs. Strings is one of the most common data structure in most programming language. One common thing we wish to do with String is to clean it up. One common way of cleaning up Strings is by removing spaces from the beginning and the end of the value. For example, when we want to save first name or last name, having spaces at the beginning or the end of a name doesn't make sense. So we want to remove them. This is where the Java String's Trim() method comes in handy. This is what it exactly do. Below are more discussion about how to use Trim method of Java String.

Java Switch String

The switch statement is a beautiful alternative to multiple if else, when all we want to do is match a variable's value to one of many values, to determine what to do. The switch statement is both concise, readable, and have better performance compared to multiple if else version. One issue though, before Java 7 was introduced, we can't use String value with switch statements. That is not fun as String is a well used data type. Sometimes we don't want to define enum and just want to work with Strings. Below are some way on how to use String in Java Switch statements.

String Append Java

Most String manipulation problems requires us to come up with combination of information and summarize into one String. For example, imagine we wish to convert an integer value into words as String, this will require us to combine multiple Strings to come up with an answer String. What is common to this is we need to append one String to another, to form a closer form to the answer. Below we explore how to do String Append in Java.