mike o'connor
java pig latin
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners

how do you add the first letter of a word to the end of the word

Ads

View Answers

November 19, 2010 at 11:42 AM


Hi Friend,

If you want to remove the first letter of your word and add it at the end of the same word,try the following code:

import java.util.*;

class Word{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Word: ");
        String word = input.next();
        char ch=word.charAt(0);
        String st=word.replace(Character.toString(ch),"");
        String newWord=st+Character.toString(ch);
        System.out.println(newWord);
    }
}

And if you simply want to add the first letter of word to the end of same word without removing the letter, then try the following:

import java.util.*;

class Word{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Word: ");
        String word = input.next();
        char ch=word.charAt(0);
        String newWord=word+Character.toString(ch);
        System.out.println(newWord);
    }
}

Thanks










Related Tutorials/Questions & Answers:
java pig latin
java pig latin  how do you add the first letter of a word to the end of the word   Hi Friend, If you want to remove the first letter of your word and add it at the end of the same word,try the following code: import
Java Word Processor
reads the same forwards as backwards) ? return a Pig Latin version of the text... this method do its work. To convert a word to Pig Latin: o if the word begins... not be included in the middle of a Pig Latin version of a word but should
Advertisements
what is a indentifier - Java Beginners
) returns true. The Java letters include uppercase and lowercase ASCII Latin letters... is the definition?  An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. An identifier cannot
Java program - Java Beginners
Java program  Dear maam/Sir, I am a 2nd year Computer... not that familiar with java environment.. My friend told me that you can help me with my...{ if ((x == 2) || (x == -10)){ chineseSign="Pig
Simple ATM Java Code...
Simple ATM Java Code...  You are required to write a Graphical User Interface that simulates an ATM by building on the program you wrote... 1004.04 Porky Pig 5678 1005.05 (you may rearrange the data
java
java  diff bt core java and java
java
java  what is java
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
Java
Java   Whether Java is pure object oriented Language
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java

Ads

Advertisement