Powered by Blogger.
Showing posts with label Strings. Show all posts
Showing posts with label Strings. Show all posts

strip only the numbers from any formatted string of phone number

>> Thursday, April 23, 2020

This is a method which returns a string contains numbers init.The phone numbers may contain in differnt formats Ex: (123) 456-7890
                                 123-456-7890
so we can read these type of characters and returns only the numbers using java method isDigit from Character class.

Read more..

Display first fetter of a word with Capital letter in a given Sentence or String

>> Friday, February 28, 2020

The below code will display every first letter of a word in the sentence will display as a capital letter or in Camel Case using java program.
CamelCase Words in the Sentence

Read more..

Best practice to find Duplicate Character from a String in java

>> Sunday, June 28, 2015

This program could be the best way to find the number of duplicate characters from the given String. Here we are using Map and Set from java.util.Collections package. In the below program we are using Set to collect different characters from the given String. One boolean variable and one method named as findDuplicateChar(String myString) to find the duplicates. Also some known methods like toCharArray() to convert String to character array and for-each loop to iterate Set and Array. Better you can go through the given program to find duplicate characters from the given String.
Find duplicate characters program_JavabynataraJ

Read more..

How to Reverse a String (Sentence) in Java

>> Sunday, April 22, 2012

Reverse a String the form of words we are taking the help of StringTokenizer class it is having six featured methods in its class. We can use two of them. First apply StringTokenizer on the String then Split the sentence to words using delimiter. Then push all the words into Stack class. At last pop all words from Stack.

We can form a reverse sentence in this easy way as show below diagram.

Read more..

Java program to print word for the given number

>> Saturday, October 8, 2011

Converting a number to characters or to words as readable format in text will be done easily using arrays in java. Based on the given number we can write our logic. But here i am taking the number below to 10000. So we can complete our program easily. But sure, you will understand the logic. It is simple.using Fibonacci logic , using modulo operator and divider operator we can completer our program. This is important interview question and some of like, Reverse an array, matrix addition, matrix multiplication using arrays and prime number logic these are important for the java interviews.
Convert number to Word or Characters_JavabynataraJ
In this program we have to create two arrays one is ones array with the words of one,two,three.....nineteen. Then create another array with tens array contains ten,twenty,.....ninety.
Then write the given logic to convert a number into character.

Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.