
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Karthikeya Boyini has Published 2193 Articles

karthikeya Boyini
149 Views
Here is our character array.char[] ch = { 'T', 'E', 'S', 'T', 'I', 'N', 'G'};Create string object from some part of a string using the following String constructor. Through this we are fetching substring “IN” from the character array.String str = new String(ch, 4, 2);Example Live Demopublic class Demo { ... Read More

karthikeya Boyini
4K+ Views
To extract a substring as an array of characters in Java, use the getChars() method.Let’s say the following is our string and character array.String str = "World is not enough!"; char[] chArr = new char[10];Now, use the getChars() method to extract a substring.str.getChars(13, 19, chArr, 0);The above substring is an ... Read More

karthikeya Boyini
489 Views
To construct on string from another, firstly take a charcter array for the first string.char ch[] = { 'A', 'M', 'I', 'T' }; String str1 = new String(ch);The above forms first string. Now, let us created another string from the first string.String str2 = new String(str1);In this way, we can ... Read More

karthikeya Boyini
6K+ Views
To display number with thousands separator, set a comma flag.System.out.printf( "%, d", 78567);The above would result.78, 567Let’s check for bigger numbers.System.out.printf( "%, d", 463758);The above would result.463, 758Example Live Demopublic class Demo { public static void main( String args[] ) { System.out.printf( "%, d", 95647 ); ... Read More

karthikeya Boyini
445 Views
To display seconds since the epoch, use the ‘s’ Date and Time conversion specifier.System.out.printf("Seconds since epoch = %ts", d);The above would display seconds since.1970-01-01 00:00:00 GMTExample Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); ... Read More

karthikeya Boyini
122 Views
Locale-specific morning/afternoon indicator is the AM/PM marker indicator.Use the ‘p’ conversion character to display AM/PM.System.out.printf("Morning/afternoon indicator: %tp", d);Example Live Demoimport java.util.Date; public class Demo { public static void main(String[] args) { Date d = new Date(); System.out.printf("Morning/afternoon indicator: %tp", d); System.out.printf("Morning/afternoon ... Read More

karthikeya Boyini
516 Views
Use the ‘c’ date conversion character to display UNIX date format in Java.System.out.printf("Unix date format: %tc", d);Above, d is a date object.Date d = new Date();Example Live Demoimport java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d ... Read More

karthikeya Boyini
395 Views
Floating-point conversion characters include the following.CharacterDescription%edecimal number in computerized scientific notation%Edecimal number in computerized scientific notation%fdecimal number%gbased on computerized scientific notation or decimal format, %Gbased on computerized scientific notation or decimal format, Example Live Demopublic class Demo { public static void main(String[] args) throws Exception { System.out.printf("Integer ... Read More

karthikeya Boyini
1K+ Views
Let’s say we have the following string.String str = "Demo Text!";To copy some part of the above string, use the getChars() method.// copy characters from string into chArray =str.getChars( 0, 5, chArray, 0 );The following is an example to copy characters from string into char Array in Java.Example Live Demopublic class ... Read More

karthikeya Boyini
710 Views
The Integer.toOctalString() method in Java converts int to octal string.Let’s say the following are our integer values.int val1 = 9; int val2 = 20; int val3 = 2;Convert the above int values to octal string.Integer.toOctalString(val1); Integer.toOctalString(val2); Integer.toOctalString(val3);Example Live Demopublic class Demo { public static void main(String[] args) { ... Read More