Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to display combination of char and interger

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post how to display combination of char and interger

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
     
    package tokens;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.nio.Buffer;
    import java.util.StringTokenizer;
     
    /**
    *
    * @author Gottumukkala
    */
    public class Main {
     
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args)throws IOException {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.print("enter name,house no.,street name,city name,post code:" );
    String str=br.readLine();
    StringTokenizer st= new StringTokenizer(str,",");
    String s1=st.nextToken();
    String s2=st.nextToken();
    String s3=st.nextToken();
    String s4=st.nextToken();
    String s5=st.nextToken();
    s1=s1.trim();
    s2=s2.trim();
    s3=s3.trim();
    s4=s4.trim();
    s5=s5.trim();
    String name=s1;
    int number=Integer.parseInt(s2);
    String street=s3;
    String city=s4;
    int ps=Integer.parseInt(s5);
    System.out.println("Name="+name);
    System.out.println("House no.="+number);
    System.out.println("Street name="+street);
     
    System.out.println("city name="+city);
     
    System.out.println("post code="+ps);
     
    }
     
    }

    i need to display post code which is combination of string and integer.. for example post code is ST4 2EU
    BUT i dont how to display it ... can please any one help me thank you friends
    Last edited by JavaPF; April 22nd, 2010 at 08:01 AM. Reason: Please use code tags and post in the correct forum


  2. #2
    Member
    Join Date
    Apr 2010
    Location
    The Hague, Netherlands
    Posts
    91
    Thanks
    3
    Thanked 10 Times in 10 Posts

    Default Re: how to display combination of char and interger


  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: how to display combination of char and interger

    Why can't you store the post code as a String?

    Take a look at this example:

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
     
    public class UserInput {
     
     public static void main(String[] args) {
     
       try {
       InputStreamReader is = new InputStreamReader(System.in);
       BufferedReader br = new BufferedReader(is);
     
       System.out.println("What is your post code?: ");
     
       String s = br.readLine();
     
       System.out.println("Your post code is: " + s);
       }
       catch (IOException e) 
       {
       e.printStackTrace();
      }
     }
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Display file name
    By Puk284 in forum Java Servlet
    Replies: 1
    Last Post: April 13th, 2010, 03:13 AM
  2. [SOLVED] Char cannot be dereferenced
    By zukipuu in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 17th, 2010, 11:13 PM
  3. Char cannot be dereferenced!! Please help
    By humdinger in forum Object Oriented Programming
    Replies: 5
    Last Post: February 14th, 2010, 03:18 PM
  4. display time
    By kalees in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 1st, 2010, 07:40 AM
  5. char (toUppercase?)
    By chronoz13 in forum Java Theory & Questions
    Replies: 4
    Last Post: December 12th, 2009, 10:01 AM