lang, util, io, text (optional) packages

Discussion in 'Java' started by NickName, Dec 20, 2006.

  1. NickName

    NickName Guest

    Hi,

    Following an advice on getting started with the very foundametal
    elements of java, would one one write some simple and yet elegant code
    sample using some core methods from java.lang, java.util and java.io
    (optional) and java.text (optional) packages? And if this little thing
    is fun for you, I'd appreciate it.

    TIA.
    NickName, Dec 20, 2006
    #1
    1. Advertising

  2. NickName

    Oliver Wong Guest

    "NickName" <> wrote in message
    news:...
    > Hi,
    >
    > Following an advice on getting started with the very foundametal
    > elements of java, would one one write some simple and yet elegant code
    > sample using some core methods from java.lang, java.util and java.io
    > (optional) and java.text (optional) packages? And if this little thing
    > is fun for you, I'd appreciate it.


    You're asking someone to post source code using classes from the above
    packages?

    - Oliver
    Oliver Wong, Dec 20, 2006
    #2
    1. Advertising

  3. NickName

    NickName Guest

    Oliver Wong wrote:
    > "NickName" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Following an advice on getting started with the very foundametal
    > > elements of java, would one one write some simple and yet elegant code
    > > sample using some core methods from java.lang, java.util and java.io
    > > (optional) and java.text (optional) packages? And if this little thing
    > > is fun for you, I'd appreciate it.

    >
    > You're asking someone to post source code using classes from the above
    > packages?
    >
    > - Oliver


    Yes, exactly, sorry, I hesitated a second on "using core methods", it
    should be "using core classes".
    NickName, Dec 20, 2006
    #3
  4. NickName

    Oliver Wong Guest

    "NickName" <> wrote in message
    news:...
    >
    > Oliver Wong wrote:
    >> "NickName" <> wrote in message
    >> news:...
    >> > Hi,
    >> >
    >> > Following an advice on getting started with the very foundametal
    >> > elements of java, would one one write some simple and yet elegant code
    >> > sample using some core methods from java.lang, java.util and java.io
    >> > (optional) and java.text (optional) packages? And if this little thing
    >> > is fun for you, I'd appreciate it.

    >>
    >> You're asking someone to post source code using classes from the
    >> above
    >> packages?
    >>

    >
    > Yes, exactly


    http://www.exampledepot.com/egs/java.util/pkg.html
    http://www.exampledepot.com/egs/java.io/pkg.html
    http://java.sun.com/docs/books/chanlee/second_edition/vol1/examples.html
    http://www.exampledepot.com/egs/java.text/pkg.html

    - Oliver
    Oliver Wong, Dec 20, 2006
    #4
  5. NickName

    Oliver Wong Guest

    "Oliver Wong" <> wrote in message
    news:yshih.129844$...
    >
    > "NickName" <> wrote in message
    > news:...
    >>
    >> Oliver Wong wrote:
    >>>
    >>> You're asking someone to post source code using classes from the
    >>> above
    >>> packages?
    >>>

    >>
    >> Yes, exactly

    >
    > http://www.exampledepot.com/egs/java.util/pkg.html
    > http://www.exampledepot.com/egs/java.io/pkg.html
    > http://java.sun.com/docs/books/chanlee/second_edition/vol1/examples.html
    > http://www.exampledepot.com/egs/java.text/pkg.html
    >


    Oops, forgot to mention how I found these. I googled for "java.util
    examples", "java.io examples", and "java.text examples".

    - Oliver
    Oliver Wong, Dec 20, 2006
    #5
  6. NickName

    NickName Guest

    Oliver Wong wrote:
    > "NickName" <> wrote in message
    > news:...
    > >
    > > Oliver Wong wrote:
    > >> "NickName" <> wrote in message

    > > [..]
    > >
    > > Yes, exactly

    >
    > http://www.exampledepot.com/egs/java.util/pkg.html
    > http://www.exampledepot.com/egs/java.io/pkg.html
    > http://java.sun.com/docs/books/chanlee/second_edition/vol1/examples.html
    > http://www.exampledepot.com/egs/java.text/pkg.html
    >
    > - Oliver


    The references are great, thanks, however, it would be more
    fun/interesting when some java guru writes some little code that seems
    to solve a particular problem or even several problems at one shot,
    that's the reason why I did not google for it (notice my post entitled
    "alias"? the results of which is quite fruitful and fun).
    NickName, Dec 20, 2006
    #6
  7. NickName wrote:
    ....
    > ...that's the reason why I did not google for it (notice my post entitled
    > "alias"? the results of which is quite fruitful and fun).


    The title was so stupid and boring I did not bother
    to read the thread content. This title was less stupid,
    it got me curious enough to read the post and determine
    if you deserved further attention..

    Andrew T.
    Andrew Thompson, Dec 20, 2006
    #7
  8. NickName

    NickName Guest

    Re: One for Three?

    Addition to my OP. Use one sample code to cover three packages of
    java.lang (implicit), java.util and java.io. And make it fun, are you
    able to?

    TIA.

    Andrew Thompson wrote:
    > NickName wrote:
    > ...
    > > ...that's the reason why I did not google for it (notice my post entitled
    > > "alias"? the results of which is quite fruitful and fun).

    >
    > The title was so stupid and boring I did not bother
    > to read the thread content. This title was less stupid,
    > it got me curious enough to read the post and determine
    > if you deserved further attention..
    >
    > Andrew T.


    Ok, you have a point. But you did not address the problem in question,
    so, in that sense, useless.
    NickName, Dec 20, 2006
    #8
  9. NickName

    Oliver Wong Guest

    Re: One for Three?

    "NickName" <> wrote in message
    news:...
    > Addition to my OP. Use one sample code to cover three packages of
    > java.lang (implicit), java.util and java.io. And make it fun, are you
    > able to?
    >
    > TIA.


    Because of the strange way human psychology works, when you make it
    sound like you're "tricking us" into helping you (e.g. by masquerading the
    request for help as a challenge or contest), we're less likely to help you,
    despite the fact that had you just asked straightforwardly, we would have
    been willing to help you for free. Crazy, isn't it? I'll never understand
    the human mind...

    Good luck with your challenge, though.

    - Oliver
    Oliver Wong, Dec 20, 2006
    #9
  10. "NickName" <> wrote in message
    news:...
    > Hi,
    >
    > Following an advice on getting started with the very foundametal
    > elements of java, would one one write some simple and yet elegant code
    > sample using some core methods from java.lang, java.util and java.io
    > (optional) and java.text (optional) packages?


    Sure; what kind of hourly rate were you thinking of paying?
    Mike Schilling, Dec 21, 2006
    #10
  11. NickName

    Lew Guest

    Re: One for Three?

    "NickName" <> wrote:
    >> Following an advice on getting started with the very foundametal
    >> elements of java, would one one write some simple and yet elegant code
    >> sample using some core methods from java.lang, java.util and java.io
    >> (optional) and java.text (optional) packages? And if this little thing
    >> is fun for you, I'd appreciate it.
    >>
    >> Addition to my OP. Use one sample code to cover three packages of
    >> java.lang (implicit), java.util and java.io. And make it fun, are you
    >> able to?
    >>
    >> TIA.


    Oliver Wong wrote:
    > Because of the strange way human psychology works, when you make it
    > sound like you're "tricking us" into helping you (e.g. by masquerading the
    > request for help as a challenge or contest), we're less likely to help you,
    > despite the fact that had you just asked straightforwardly, we would have
    > been willing to help you for free. Crazy, isn't it? I'll never understand
    > the human mind...
    >
    > Good luck with your challenge, though.
    >
    > - Oliver


    /** This is Fun.
    */
    public class Fun
    {
    /** Main method.
    * @param args <code>java.lang.String []</code> arguments.
    */
    public static void main( String [] args )
    {
    java.util.Map<String, String> map =
    new java.util.HashMap<String, String> ();
    map.put( "", "" );
    System.out.println( java.text.DateFormat.getDateInstance()
    .format(new Date()) +": "+ map );
    }
    }

    - Lew
    Lew, Dec 21, 2006
    #11
  12. "NickName" <> wrote in news:1166650287.007034.105360@
    79g2000cws.googlegroups.com:

    > Subject: Re: lang, util, io, text (optional) packages
    > From: "NickName" <>
    > Newsgroups: comp.lang.java.programmer
    >
    >
    > Oliver Wong wrote:
    >> "NickName" <> wrote in message
    >> news:...
    >> >
    >> > Oliver Wong wrote:
    >> >> "NickName" <> wrote in message
    >> > [..]
    >> >
    >> > Yes, exactly

    >>
    >> http://www.exampledepot.com/egs/java.util/pkg.html
    >> http://www.exampledepot.com/egs/java.io/pkg.html
    >> http://java.sun.com/docs/books/chanlee/second_edition/vol1/examples.htm
    >> l http://www.exampledepot.com/egs/java.text/pkg.html
    >>
    >> - Oliver

    >
    > The references are great, thanks, however, it would be more
    > fun/interesting when some java guru writes some little code that seems
    > to solve a particular problem or even several problems at one shot,


    The ONLY way for YOU to learn how to program in Java using the classes in
    these various classes is for YOU to write programs in Java that uses the
    classes in these various classes.

    Cheers
    GRB

    --
    ---------------------------------------------------------------------
    Greg R. Broderick

    A. Top posters.
    Q. What is the most annoying thing on Usenet?
    ---------------------------------------------------------------------
    Greg R. Broderick, Dec 21, 2006
    #12
  13. Re: One for Three?

    "NickName" <> wrote in
    news::

    > Addition to my OP. Use one sample code to cover three packages of
    > java.lang (implicit), java.util and java.io. And make it fun, are you
    > able to?


    No, we will not do your homework assignment for you.

    --
    ---------------------------------------------------------------------
    Greg R. Broderick

    A. Top posters.
    Q. What is the most annoying thing on Usenet?
    ---------------------------------------------------------------------
    Greg R. Broderick, Dec 21, 2006
    #13
  14. NickName

    NickName Guest

    Re: One for Three?

    Lew wrote:
    > "NickName" <> wrote:
    > [...]
    >
    > /** This is Fun.
    > */
    > public class Fun
    > {
    > /** Main method.
    > * @param args <code>java.lang.String []</code> arguments.
    > */
    > public static void main( String [] args )
    > {
    > java.util.Map<String, String> map =
    > new java.util.HashMap<String, String> ();
    > map.put( "", "" );
    > System.out.println( java.text.DateFormat.getDateInstance()
    > .format(new Date()) +": "+ map );
    > }
    > }
    >
    > - Lew


    OK, this is kind of interesting. It looks like with parameters of
    coordinates of x and y,
    it would generate a simple map with today's date, yes?

    Here's the code with IDE, JBuider 2005:
    ----------------------------------------------------------
    package fun;

    import java.util.*;
    import java.text.*;

    /**
    * <p>Title: </p>
    *
    * <p>Description: </p>
    *
    * <p>Copyright: Copyright (c) 2006</p>
    *
    * <p>Company: </p>
    *
    * @author not attributable
    * @version 1.0
    */

    /* Generate a simple map.
    */

    public class AboutMap {
    /** Main method.
    * @param args <code>java.lang.String []</code> arguments.
    */
    public static void AboutMap( String [] args )
    {
    Map<String, String> map =
    new HashMap<String, String> ();
    map.put( "", "" );
    // question, the put method is putting nothing there? How come?

    System.out.println( java.text.DateFormat.getDateInstance()
    .format(new Date()) +": "+ map );
    }
    }
    ------------------------------------------------------

    Err msg:
    java.lang.NoSuchMethodError: main

    FYI, I'm using jre1.5 as its compiler. I explicitly added
    import java.lang.String;
    to no avail.

    What's wrong?

    Thanks.
    NickName, Dec 26, 2006
    #14
  15. Re: One for Three?

    "NickName" <> wrote in message
    news:...

    > package fun;
    >
    > import java.util.*;
    > import java.text.*;
    >
    > /**
    > * <p>Title: </p>
    > *
    > * <p>Description: </p>
    > *
    > * <p>Copyright: Copyright (c) 2006</p>
    > *
    > * <p>Company: </p>
    > *
    > * @author not attributable
    > * @version 1.0
    > */
    >
    > /* Generate a simple map.
    > */
    >
    > public class AboutMap {
    > /** Main method.
    > * @param args <code>java.lang.String []</code> arguments.
    > */
    > public static void AboutMap( String [] args )
    > {
    > Map<String, String> map =
    > new HashMap<String, String> ();
    > map.put( "", "" );
    > // question, the put method is putting nothing there? How come?
    >
    > System.out.println( java.text.DateFormat.getDateInstance()
    > .format(new Date()) +": "+ map );
    > }
    > }
    > ------------------------------------------------------
    >
    > Err msg:
    > java.lang.NoSuchMethodError: main
    >
    > FYI, I'm using jre1.5 as its compiler. I explicitly added
    > import java.lang.String;
    > to no avail.
    >
    > What's wrong?



    Try renaming the method called "AboutMap" to "main"..
    Mike Schilling, Dec 26, 2006
    #15
  16. NickName

    NickName Guest

    Re: One for Three?

    Mike Schilling wrote:
    > "NickName" <> wrote in message
    > news:...
    >

    OP [...]
    >
    > Try renaming the method called "AboutMap" to "main"..

    Excellent, thank you. So, it seems that one of the rules is that any
    java program must have one class named "main" with source file name of
    main.java. Yes?

    New err msg:
    Hit uncaught exception java.lang.ClassNotFoundException

    I thought the program would prompt a user for two parameters of
    coordinates of x and y.

    Also, JBuilder 2005 loaded URLClassLoader file when I ran the program
    in debug mode. What's exactly going on?

    Many thanks.
    NickName, Dec 27, 2006
    #16
  17. Re: One for Three?

    "NickName" <> wrote in message
    news:...
    >
    > Mike Schilling wrote:
    >> "NickName" <> wrote in message
    >> news:...
    >>

    > OP [...]
    >>
    >> Try renaming the method called "AboutMap" to "main"..

    > Excellent, thank you. So, it seems that one of the rules is that any
    > java program must have one class named "main" with source file name of
    > main.java. Yes?


    No, a *method* named main, not a *class* named main. E.g.

    public class Hello
    {
    public static void main(String[] args)
    {
    System.out.println("Hello, world");
    }
    }

    Really, you should read an introductory book about Java to learn this sort
    of terminology.
    Mike Schilling, Dec 27, 2006
    #17
  18. NickName

    NickName Guest

    Re: One for Three?

    Mike Schilling wrote:
    > "NickName" <> wrote in message
    > news:...
    > [...]
    >
    > No, a *method* named main, not a *class* named main. E.g.
    >
    > public class Hello
    > {
    > public static void main(String[] args)
    > {
    > System.out.println("Hello, world");
    > }
    > }


    Got it. Compiled and it runs. Many thanks. Now, a related question,
    I attempted to use
    the coordinates of 38°53'50"N 77°0'22"W for Union Station (DC) and
    since the program does not prompt me for param input, I manually edited
    the source code for the map.put method to
    read as
    map.put( "38°53'50\"N", "77°0'22\"W" );
    // thought one backslash character is to escape special character like
    quote

    The code runs just fine. The debug console prints the following:
    Dec 27, 2006: {38°53'50"N=77°0'22"W}

    However, that seems meaningless unless I did not use it correctly. I
    was expecting some sort of map albeit simple.

    >
    > Really, you should read an introductory book about Java to learn this sort
    > of terminology.


    Yes, will do. Thanks.
    NickName, Dec 27, 2006
    #18
  19. NickName

    Oliver Wong Guest

    Re: One for Three?

    "NickName" <> wrote in message
    news:...
    >
    > Mike Schilling wrote:
    > > "NickName" <> wrote in message
    > > news:...
    > > [...]
    > >
    > > No, a *method* named main, not a *class* named main. E.g.
    > >
    > > public class Hello
    > > {
    > > public static void main(String[] args)
    > > {
    > > System.out.println("Hello, world");
    > > }
    > > }

    >
    > Got it. Compiled and it runs. Many thanks. Now, a related question,
    > I attempted to use
    > the coordinates of 38°53'50"N 77°0'22"W for Union Station (DC) and
    > since the program does not prompt me for param input, I manually edited
    > the source code for the map.put method to
    > read as
    > map.put( "38°53'50\"N", "77°0'22\"W" );
    > // thought one backslash character is to escape special character like
    > quote
    >
    > The code runs just fine. The debug console prints the following:
    > Dec 27, 2006: {38°53'50"N=77°0'22"W}
    >
    > However, that seems meaningless unless I did not use it correctly. I
    > was expecting some sort of map albeit simple.


    You DO have a simple map. More specifically, you have a string
    representation of a map which has a single point as it's domain
    ("38°53'50"N") and a single point as it's range ("77°0'22"W"). Perhaps the
    confusion arises because you were expecting some sort of geographical map?
    "Map" here is in the mathematical sense:

    http://en.wikipedia.org/wiki/Map_(mathematics)
    http://www.purplemath.com/modules/fcns2.htm

    - Oliver
    Oliver Wong, Dec 27, 2006
    #19
  20. NickName

    NickName Guest

    Re: One for Three?

    Oliver Wong wrote:
    > "NickName" <> wrote in message
    > news:...
    > >
    > > [...]


    > > Got it. Compiled and it runs. Many thanks. Now, a related question,
    > > I attempted to use
    > > the coordinates of 38°53'50"N 77°0'22"W for Union Station (DC) and
    > > since the program does not prompt me for param input, I manually edited
    > > the source code for the map.put method to
    > > read as
    > > map.put( "38°53'50\"N", "77°0'22\"W" );
    > > // thought one backslash character is to escape special character like
    > > quote
    > >
    > > The code runs just fine. The debug console prints the following:
    > > Dec 27, 2006: {38°53'50"N=77°0'22"W}
    > >
    > > However, that seems meaningless unless I did not use it correctly. I
    > > was expecting some sort of map albeit simple.

    >
    > You DO have a simple map. More specifically, you have a string
    > representation of a map which has a single point as it's domain
    > ("38°53'50"N") and a single point as it's range ("77°0'22"W"). Perhaps the
    > confusion arises because you were expecting some sort of geographical map?
    > "Map" here is in the mathematical sense:
    >
    > http://en.wikipedia.org/wiki/Map_(mathematics)
    > http://www.purplemath.com/modules/fcns2.htm
    >
    > - Oliver


    But this is oxymoronic. First of all, 38°53'50"N=77°0'22"W is
    plainly wrong,
    38°53'50"N <> 77°0'22"W,
    one of them is longtitude and the other is latitude and the print out
    is meaningless as far as I'm concerned. But if you're saying using
    them for further calculation or processing (in math term) then that
    would make sense. It's kind of an interesting start for Lew to post
    it, however, it needs a step further for any value.

    Thanks.
    NickName, Dec 27, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mgalaty
    Replies:
    0
    Views:
    2,722
    mgalaty
    Sep 10, 2004
  2. Anna
    Replies:
    0
    Views:
    2,005
  3. Replies:
    0
    Views:
    367
  4. BoBi
    Replies:
    3
    Views:
    4,188
  5. Lawrence D'Oliveiro

    java.lang vs java.util

    Lawrence D'Oliveiro, Apr 2, 2011, in forum: Java
    Replies:
    25
    Views:
    1,268
    Lawrence D'Oliveiro
    May 5, 2011
Loading...

Share This Page