print initials

print initials

How to print initials of a name without using arrays?

View Answers

November 16, 2010 at 11:41 AM

Hi Friend,

You can try the following code:

import java.util.*;

public class InitialName {
        public static void main(String[] args) {
         Scanner input=new Scanner(System.in);
         System.out.println("Enter Name");
         String name=input.nextLine();
         input.close();
         int index = name.lastIndexOf( " " ) + 1;
         String st= name.substring(0,index);
         Scanner scan=new Scanner(st);
         while(scan.hasNext()){
         System.out.print(scan.next().charAt(0)+".");
         }
         scan.close();
         System.out.print(name.substring(index));
        }
}

Thanks


January 18, 2011 at 7:49 PM

iwant with out public static void main


July 31, 2011 at 7:19 PM

how to do it without using index of and last index of functions ????????









Related Tutorials/Questions & Answers:
To print initials
To print initials  import java.util.Scanner; class initials { String a ; int e ; char f ; int b ; int c ; char d; Scanner sc = new...); System.out.println("The initials are :" + f
print initials
print initials  How to print initials of a name without using arrays?   Hi Friend, You can try the following code:ADS_TO_REPLACE_1 import java.util.*; public class InitialName { public static void main(String
Advertisements
Print initials of the input name
Print initials of the input name In this section, you will come to know how to display the initials of the given name. For this, user will have to input the name. This name in the form of string is then split into the words with the split
ModuleNotFoundError: No module named 'initials-avatar'
ModuleNotFoundError: No module named 'initials-avatar'  Hi, My... named 'initials-avatar' How to remove the ModuleNotFoundError: No module named 'initials-avatar' error? Thanks   Hi, In your python
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
Print
into the stream and, as opposed to print() method, gets you to the new line after the text
ModuleNotFoundError: No module named 'print_print'
ModuleNotFoundError: No module named 'print_print'  Hi, My Python... 'print_print' How to remove the ModuleNotFoundError: No module named 'print_print' error? Thanks   Hi, In your python environment
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
Print Button
Print Button  i want the source code for printing details of jform.. so plz help me for source code of print button
print the newline
print the newline  Why doesn?t the following code print the newline properly? <?php $str = ?Hello, there.\nHow are you?\nThanks for visiting.?; print $str; ?>   Hi friends, Inside the single quotes \n (newline
print numbers
print numbers  1234 123 12 1234   1234 123 12 1234
Print the document
Print the document  I tried to print web page.I am using the below...() { var printWindow = window.open('test', 'Print Window', 'height=600,width...;Print Window</title>'); printWindow.document.write('</head>
Print the document
Print the document  I tried to print web page.I am using the below...() { var printWindow = window.open('test', 'Print Window', 'height=600,width...;Print Window</title>'); printWindow.document.write('</head>
Print a statement
Print a statement  hello what would we output for this statement System.out.println ("5"+"A" + 3);   helloADS_TO_REPLACE_1 output will be 5A3
date print
date print  how can i print the date in jsp page in the following formate month-date-year. (example. march 8 2012
date print
date print  how can i print the date in jsp page in the following formate month-date-year. (example. march 8 2012
print the sequence
print the sequence  how can I write the code by using for loop to produce this following statement: 10,9,8,7,6,5,4,3,2,1,buzz! please, help me
diamond print
diamond print   print the pattern 1 2 3 4 5 6 7 8 9 10 11 12
Print command
Print command  Can I use System.out.println command in Struts form bean or Struts action class. I am using Struts 1.3.8 but when I write this command. It does not work. Please reply me as soon as possible. Thanks.   
should print in console
should print in console  
print form information when click on print button
print form information when click on print button   Sir,I desingn institute webside using jsp and strut by using platform netbean 7.2.So request you please help for printing form information by clickin print button after submit
how to print the server time
how to print the server time  how to print the server time in jsp and update time in fix interval
echo and print statement
echo and print statement  hello, What is the difference between echo and print statement
print square of any number
print square of any number  using c++ language, write aprogram to print the square of any number entered by the user
print without newline in python
print without newline in python  Hi, I have a Python program... the print it in one line. My example: print("I ") print("Love ") print("Python") But the output is coming in new lines. I want to know how to print without
print without newline in python
print without newline in python  Hi, I have a Python program... the print it in one line. My example:ADS_TO_REPLACE_1 print("I ") print("Love ") print("Python") But the output is coming in new lines. I want to know how
ModuleNotFoundError: No module named 'print'
ModuleNotFoundError: No module named 'print'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'print' How to remove the ModuleNotFoundError: No module named 'print'
ModuleNotFoundError: No module named 'print_it'
ModuleNotFoundError: No module named 'print_it'  Hi, My Python... 'print_it' How to remove the ModuleNotFoundError: No module named 'print... to install padas library. You can install print_it python with following
How to print this Format exactly?
How to print this Format exactly?   * * * & reverse
Print the following format
Print the following format  how to print the following format given string "00401121" in java 0-** 1-* 2-* 3- 4
echo and print statement
echo and print statement  hello, What is the difference between echo and print statement?   hii,ADS_TO_REPLACE_1 echo() can take multiple expressions, Print() cannot take multiple expressions. And echo is a little
print variable in iphone
print variable in iphone  how can i print a variable in iphone????   hello,, if you want to print a variable in objective CADS_TO_REPLACE_1 if integer then int i=3; NSLog(@"%d",i);ADS_TO_REPLACE_2 if string
How to print this in java?
How to print pattern in Java?  How to print a particular pattern in Java...;  How to print this in java
noise during print screen
noise during print screen  hi there, i have a java program which can print screen every 1 seconds... but during the print screen, the image seems will have some noise and ends up half page of the image will be black screen
how to print the server time
how to print the server time  i want to print database time in clintside and update time in every secound without creating connection to database for each time. how can i do
print word with max vowels
print word with max vowels  if suppose i hava entered a sentence and in that sentence i have to print a word which has maximum vowels in it.... i have tried it but i am not getting it...please help
how to print String as pattern ?
how to print String as pattern ?  i have a one String name ="rajesh" i want to print pattern like r * ra ** raj raje rajes rajesh please help me
Clear the print button after onclicking the print - Ajax
Clear the print button after onclicking the print  var disp_setting...=yes,width=700, height=330,left=300,top=325"; var rate_print=window.open..., this is my script using for creating table. see print button onclick function
How to design a foot print on the sand, print on the sand, print
How to design a foot print on the sand       You might have seen foot prints on the sand field. Do you think, it can be design in the photoshop, yes I have done here. I have used
Print in a long paper - Java Beginners
Print in a long paper  how to print text in long paper?? each print text, printer stops. not continue until the paper print out. Thanks
program to print total marks
program to print total marks  program to input total marks out of 600 marks as an argument and print the stream allotted using the following criteria 401 & above - PCM 301-400 - ZBC 201-300- Commerce 101-200 - Arts
print the below pattern
print the below pattern  to write a program using a function ti initialize a character 'A' and print the following pattern of characters upto six lines A A B A B C A B C D A B C D E A B C D E F
write a program to print
write a program to print   write a program to print following 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1
Print Form - Java Beginners
Print Form  Hello Sir I have Created Admission Form when user fills data and submit that data to access database,then when i Click on PRINT Button I want to get Print of that forms Contents,How I can Do it with JAVA SWING,plz
Application for print pyramid of numbers
Application for print pyramid of numbers  What is the code for printing the numbers like 1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
print hello n hi
print hello n hi  how to write a java program that prints "hello" 5 times, "hi" 1 time n again "hello" 4 times..?? do reply
how to print - Java Beginners
how to print  how to print something on console without using System.out.print() method ?  Hi Friend, You can use PrintWriter to write anything on the console. import java.io.*; public class Print{ public static
Java Print Dialog
Java Print Dialog  Using java.awt.print.PrinterJob and javax.print.attribute.PrintRequestAttributeSet. I call .printDialog(ps) and the standard print dialog is displayed with options preset to my chosen attributes. Now I can
A Program To Print A Equilateral Triangle
A Program To Print A Equilateral Triangle  Write A program to Print Following In Java : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334 4322234 4321234 4322234 4333334 4444444 // for input 4. And also

Ads