Numbers in Java (With 0 Prefix and with Strings) Last Updated : 30 May, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report Consider the following Java program. Java import java.io.*; class GFG { public static void main (String[] args) { int x = 012; System.out.print(x); } } Output: 10 The reason for above output is, when a 0 is prefixed the value is considered octal, since 12 in octal is 10 in decimal, the result is 10. Similarly, if i = 0112, result will be 74 (in decimal). This behavior is same as C/C++ (see this). Also, Java import java.io.*; class GFG { public static void main (String[] args) { String s = 3 + 2 + "hello" + 6 + 4; System.out.print(s); } } Output : 5hello64 Java takes the numbers before the strings are introduced as int and once the string literals are introduced, all the following numbers are considered as strings. Comment More infoAdvertise with us Next Article CompoundName startsWith() method in Java with Examples K kartik Improve Article Tags : Java Practice Tags : Java Similar Reads String matches() Method in Java with Examples In Java, the matches() method in the String class checks if a string matches a specified regular expression. It is useful for validating input patterns and searching within strings. In this article, we will learn how to use the matches() method effectively in Java with examples to illustrate its fun 3 min read NumberFormatException in Java with Examples The NumberFormatException occurs when an attempt is made to convert a string with improper format into a numeric value. Â That means, when it is not possible to convert a string in any numeric type (float, int, etc), this exception is thrown. It is a Runtime Exception (Unchecked Exception) in Java. I 3 min read Integer.numberOfTrailingZeros() Method in Java with Example The Java.lang.Integer.numberOfTrailingZeros() is the method which returns the total number of zero(0) bits following the lowest-order (ie.Rightmost or least significant "1" bit)one-bit in the two's complement binary representation of the specified integer value or we can say that it is the function 3 min read CompoundName startsWith() method in Java with Examples The startsWith() method of a javax.naming.CompoundName class is used to check whether compound name which is passed as a parameter is a prefix of this compound name or not. A compound name 'X' is a prefix of this compound name if this compound name object ends with 'X'. If X is null or not a compoun 2 min read Replace all Digits in a String with a Specific Character in Java To replace all digits in a string with a specific character in Java, we can use the regular expressions and the replaceAll() method of the String class. This method allows to search for patterns in the string and replace them with a given character or substring.Example 1: The below Java program demo 3 min read BigDecimal toPlainString() Method in Java with Examples The java.math.BigDecimal.toPlainString() method is used to represent the current BigDecimal by which this method is called into String form without an exponent field. If the values are with a positive scale, the number of digits to the right of the decimal point is used to indicate scale. For values 2 min read Like