![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9326 Articles for Object Oriented Programming
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
108 Views
To parse the octal string to create BigInteger, use the following BigInteger constructor and set the radix as 8 for Octal −BigInteger(String val, int radix)This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.In the below example, we have set the BigInteger and radix is set as 8.BigInteger one, two; one = new BigInteger("12"); two = new BigInteger("4373427", 8);The following is the complete example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two; one = new BigInteger("12"); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
225 Views
Use the toByteArray() method to return a byte array containing the two's-complement representation of this BigInteger. The byte array will be in big-endian byte-order: the most significant byte is in the zeroth element.The following is an example to retrieve the current bits in a byte array in two’s-complement form.Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { // BigInteger objects BigInteger bi1, bi2; byte b1[] = { 0x1, 0x00, 0x00 }; bi1 = new BigInteger(b1); b1 = bi1.toByteArray(); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
802 Views
The MM format is for months in two-digits 01, 02, 03, 04, etc. Here, we will use the following.SimpleDateFormat("MM");Let us see an example −// displaying month in MM format SimpleDateFormat simpleformat = new SimpleDateFormat("MM"); String strMonth = simpleformat.format(new Date()); System.out.println("Month in MM format = "+strMonth)Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
815 Views
The following is an example −Example Live Demopublic class Demo { public static void main(String[] args) { String str = "laptop"; System.out.println("Original String = " +str); // letter one String strOne = str.substring(0,1).toUpperCase(); // remaining letters String strTwo = str.substring(1).toLowerCase(); System.out.println("Resultant String = "+strOne + strTwo); } }OutputOriginal String = laptop Resultant String = Laptop
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
412 Views
The following is our string −String str = "Tim";Now take a StringBuilder object −StringBuilder strBuilder = new StringBuilder();Perform left padding and extend the string length. We have set it till 20, that would include the current string as well. The zeros that will be padded comes on the left. Append the zeros here −while (strBuilder.length() + str.length() < 10) { strBuilder.append('0'); }The following is an example −Example Live Demopublic class Demo { public static void main(String[] args) { String str = "Tim"; StringBuilder strBuilder = new StringBuilder(); while (strBuilder.length() + str.length() ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
Let us see an example first to understand how an integer looks with left padding −888 //left padding with spaces 0000000999 //left padding with 7 zerosLet us see an example to left pad a number with zero −Example Live Demopublic class Demo { public static void main(String[] args) { int val = 9899; System.out.println(String.format("%05d",val)); } }Output09899Let us see another example that pads a greater number of zeros −Example Live Demopublic class Demo { public static void main(String[] args) { int val = 9899; System.out.println(String.format("%010d", val)); } }Output0000009899
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
210 Views
Let us see an example first to understand how a string looks with left padding −demotext //left padding with spaces 0000000demotext //left padding with 7 zerosThe following is our string −String str = "Jack";Now take a StringBuilder object −StringBuilder strBuilder = new StringBuilder();Perform left padding and extend the string length. The spaces that will be padded comes on the left. Append the spaces here −while (strBuilder.length() + str.length() < 10) { strBuilder.append(' '); }The following is an example to pad a string to the left with spacesExample Live Demopublic class Demo { public static void main(String[] args) { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
169 Views
The following is our string −String str = "Amit";Now take a StringBuilder object −StringBuilder strBuilder = new StringBuilder();Set the character you want to pad with a string −Character ch = '^';Perform left padding and extend the string length to 5 (one for the additional character). The character that will be padded comes on the left −while (strBuilder.length() + str.length() < 5) { strBuilder.append(ch); }The following is an example −Example Live Demopublic class Demo { public static void main(String[] args) { String str = "Amit"; Character ch = '^'; StringBuilder strBuilder = ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
73 Views
TheBigInteger.andNot(BigInteger val) returns a BigInteger whose value is (this & ~val). This method, which is equivalent to and(val.not()), is provided as a convenience for masking operations. This method returns a negative BigInteger if and only if this is negative and val is positive. Here, “val” is the value to be complemented and AND'ed with this BigInteger.The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two, three; one = new BigInteger("12"); two = new BigInteger("6"); three = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
112 Views
TheBigInteger.or(BigInteger val) returns a BigInteger whose value is (this | val). This method returns a negative BigInteger if and only if either this or val is negative.Here, “val” is the value to be OR'ed with this BigInteger.The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] args) { BigInteger one, two, three; one = new BigInteger("6"); two = one.or(one); System.out.println("Result (or operation): " +two); } }OutputResult (or operation): 6Let us see another example −Example Live Demoimport java.math.*; public class Demo { ... Read More