Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > lang, util, io, text (optional) packages

Reply
Thread Tools

lang, util, io, text (optional) packages

 
 
Lew
Guest
Posts: n/a
 
      12-21-2006
"NickName" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Greg R. Broderick
Guest
Posts: n/a
 
      12-21-2006
"NickName" <(E-Mail Removed)> wrote in news:1166650287.007034.105360@
79g2000cws.googlegroups.com:

> Subject: Re: lang, util, io, text (optional) packages
> From: "NickName" <(E-Mail Removed)>
> Newsgroups: comp.lang.java.programmer
>
>
> Oliver Wong wrote:
>> "NickName" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) ups.com...
>> >
>> > Oliver Wong wrote:
>> >> "NickName" <(E-Mail Removed)> 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/chanl...1/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 (E-Mail Removed)

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Greg R. Broderick
Guest
Posts: n/a
 
      12-21-2006
"NickName" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) ups.com:

> 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 (E-Mail Removed)

A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      12-26-2006

Lew wrote:
> "NickName" <(E-Mail Removed)> 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.

 
Reply With Quote
 
Mike Schilling
Guest
Posts: n/a
 
      12-26-2006

"NickName" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

> 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"..


 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      12-27-2006

Mike Schilling wrote:
> "NickName" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>

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.

 
Reply With Quote
 
Mike Schilling
Guest
Posts: n/a
 
      12-27-2006

"NickName" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>
> Mike Schilling wrote:
>> "NickName" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) ups.com...
>>

> 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.


 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      12-27-2006

Mike Schilling wrote:
> "NickName" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> [...]
>
> 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 3853'50"N 770'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( "3853'50\"N", "770'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: {3853'50"N=770'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.

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      12-27-2006

"NickName" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
>
> Mike Schilling wrote:
> > "NickName" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) ups.com...
> > [...]
> >
> > 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 3853'50"N 770'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( "3853'50\"N", "770'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: {3853'50"N=770'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
("3853'50"N") and a single point as it's range ("770'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_%28mathematics%29
http://www.purplemath.com/modules/fcns2.htm

- Oliver


 
Reply With Quote
 
NickName
Guest
Posts: n/a
 
      12-27-2006

Oliver Wong wrote:
> "NickName" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ps.com...
> >
> > [...]


> > Got it. Compiled and it runs. Many thanks. Now, a related question,
> > I attempted to use
> > the coordinates of 3853'50"N 770'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( "3853'50\"N", "770'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: {3853'50"N=770'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
> ("3853'50"N") and a single point as it's range ("770'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_%28mathematics%29
> http://www.purplemath.com/modules/fcns2.htm
>
> - Oliver


But this is oxymoronic. First of all, 3853'50"N=770'22"W is
plainly wrong,
3853'50"N <> 770'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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Packages : A loomingproblem? packages might no longer work? (well not on your platform or python version anyway) David Lyon Python 19 04-23-2009 11:10 PM
Controlling text in a Text Area or Text leo ASP General 1 12-05-2005 01:13 AM
Advice on converting hashed packages to pseudo-hashed packages Ian Perl Misc 3 02-12-2005 12:17 AM
Do the javax.imageio packages replace packages in com.sun.image? Paul Smith Java 0 11-18-2003 02:58 PM



Advertisments