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.
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.
File manipulation is a common programming theme that we need to do. As we store some data into a file, it is natural for us to be able to read and write into a file. The most common file format that we encounter is just a plain text file. Which means it would be natural also to read it's contents and put the value into a String variable. In this post, we present several solution on how to Read File To String in Java. We give several solutions, specially with the recent advancement in Java.
The multiply assign operator does two operations in one statement. First is that it multiplies the value of a variable on the left side with the evaluated value of the expression on the right side. The result is assigned back to the variable. This is why it is called a compounded assign operator is because it is a short hand for two operations. Below are examples on Multiply Assign Operator in Java.
XOR or the Binary Exclusive OR operation is a common bitwise operation in any language, including Java. Below are examples on how to use Binary Exclusive OR Assign Operator in the Java programming language:
In Java, Compounded Assignment Operator combines an operation and assignment into one statement, making code concise. Below is an example on how to do it with Binary OR operation. Which is we show examples on how to use Binary AND Assign Operator in Java.
Binary Right Shift Operation is like dividing a number by a power of two while preserving sign. Binary Right Shift Zero Fill is similar, where we are dividing a number by a power of 2, but unsigned. Which means we lose the sign of the original number after shifting, because we are replacing the digits shifted to the right by 0. Which turns the result into a positive number. This post will give examples on how to use Binary Right Shift Zero Fill Assign Operator in the Java Programming Language.