Java Newbie question  
Author Message
M





PostPosted: 2004-6-2 19:57:00 Top

java-programmer, Java Newbie question Hi all, I'm learning Java 2 by myself and find question for help.

I'm testing the System.in.read() method and tried the following program:

import java.io.*;

class ReadBytes {
public static void main(String args[])
throws IOException {
byte data[] = new byte[10];

System.out.println("Enter some characters.");
System.in.read(data);
System.out.print("You entered: ");
for (int i=0; i<data.length; i++) {
System.out.print((char)data[i]);
}
}
}

My question are:
(1) if I just comment out the "throws IOException" in the main, I
just got compilation error! Is the any condition I can tell whether
I have to throw something or not? I remembered in the HelloWOrld
app, I don't have to throw anything.
(2) If I entered more than 10 characters in the above test, I didn't
get overflow error. Why? Actually I'm expected an exception to
be caught.

Thanks in advance.



 
Andrew Thompson





PostPosted: 2004-6-2 20:16:00 Top

java-programmer >> Java Newbie question On Wed, 2 Jun 2004 19:57:12 +0800, M wrote:

> Hi all, I'm learning Java 2 by myself and find question for help.

Please direct your quetions to
c.l.j.help for the moment.
<http://www.physci.org/codes/javafaq.jsp#cljh>

> I'm testing the System.in.read() method and tried the following program:
...
> My question are:
> (1) if I just comment out the "throws IOException" in the main, I
> just got compilation error! Is the any condition I can tell whether
> I have to throw something or not?

'JavaDocs'
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#in>
<http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read()>

The second link will most likey break because
of the '()', find your way from here..
<http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#method_summary>

> (2) If I entered more than 10 characters in the above test, I didn't
> get overflow error. Why?

Your code only reads the size of the array, 10
characters, then iterates through the existing 10.

Try entering 5..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Yu SONG





PostPosted: 2004-6-2 20:27:00 Top

java-programmer >> Java Newbie question M wrote:
> Hi all, I'm learning Java 2 by myself and find question for help.
>
> I'm testing the System.in.read() method and tried the following program:
>
> import java.io.*;
>
> class ReadBytes {
> public static void main(String args[])
> throws IOException {
> byte data[] = new byte[10];
>
> System.out.println("Enter some characters.");
> System.in.read(data);
> System.out.print("You entered: ");
> for (int i=0; i<data.length; i++) {
> System.out.print((char)data[i]);
> }
> }
> }
>
> My question are:
> (1) if I just comment out the "throws IOException" in the main, I
> just got compilation error! Is the any condition I can tell whether
> I have to throw something or not? I remembered in the HelloWOrld
> app, I don't have to throw anything.
> (2) If I entered more than 10 characters in the above test, I didn't
> get overflow error. Why? Actually I'm expected an exception to
> be caught.
>
> Thanks in advance.
>

Read this,
http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read(byte[])

it says "public int read(byte[] b) throws IOException", so if you use
it, you have to catch the thrown IOException.

The above article also tells you when & why the method throws the exception.


"Hello world" is here
http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintStream.html#println(java.lang.String)

It won't throw anything, so you don't need to.


--
Song

More info.:
http://www.dcs.warwick.ac.uk/~esubbn/

 
 
M





PostPosted: 2004-6-2 21:39:00 Top

java-programmer >> Java Newbie question Thanks. I'll go thru the spec.

"Yu SONG" <email***@***.com> wrote in message
news:c9kh2o$df4$email***@***.com...
> M wrote:
> > Hi all, I'm learning Java 2 by myself and find question for help.
> >
> > I'm testing the System.in.read() method and tried the following program:
> >
> > import java.io.*;
> >
> > class ReadBytes {
> > public static void main(String args[])
> > throws IOException {
> > byte data[] = new byte[10];
> >
> > System.out.println("Enter some characters.");
> > System.in.read(data);
> > System.out.print("You entered: ");
> > for (int i=0; i<data.length; i++) {
> > System.out.print((char)data[i]);
> > }
> > }
> > }
> >
> > My question are:
> > (1) if I just comment out the "throws IOException" in the main, I
> > just got compilation error! Is the any condition I can tell whether
> > I have to throw something or not? I remembered in the HelloWOrld
> > app, I don't have to throw anything.
> > (2) If I entered more than 10 characters in the above test, I didn't
> > get overflow error. Why? Actually I'm expected an exception to
> > be caught.
> >
> > Thanks in advance.
> >
>
> Read this,
>
http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read(byte[]
)
>
> it says "public int read(byte[] b) throws IOException", so if you use
> it, you have to catch the thrown IOException.
>
> The above article also tells you when & why the method throws the
exception.
>
>
> "Hello world" is here
>
http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintStream.html#println(jav
a.lang.String)
>
> It won't throw anything, so you don't need to.
>
>
> --
> Song
>
> More info.:
> http://www.dcs.warwick.ac.uk/~esubbn/
>


 
 
buzz





PostPosted: 2004-6-5 1:23:00 Top

java-programmer >> Java Newbie question I have just created my first serious applet, a dynamic graph that is fed
from an Access database. My question is, how do I stop the graph from
erasing itself when another screen is maximised in front of it?

Many thanks in advance...

Buzz


 
 
Andrew Thompson





PostPosted: 2004-6-5 1:53:00 Top

java-programmer >> Java Newbie question On Fri, 4 Jun 2004 18:23:28 +0100, buzz wrote:

> I have just created my first serious applet, a dynamic graph that is fed
> from an Access database. My question is, how do I stop the graph from
> erasing itself when another screen is maximised in front of it?

A better group for GUI matters is
<http://www.physci.org/codes/javafaq.jsp#cljg>
but a group better suited to starters is..
<http://www.physci.org/codes/javafaq.jsp#cljh>

Check this document first though
<http://www.physci.org/guifaq.jsp>
Particularly this part..
<http://www.physci.org/guifaq.jsp#2.4>

And when you go to make your next post,
you might consider an example of the problem..
<http://www.physci.org/codes/sscce.jsp>

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
 
mcwhirt3





PostPosted: 2004-11-10 9:17:00 Top

java-programmer >> Java Newbie question I need some advice on how to develop somethng. The site below has some
java applets that allow you to move some 3-d shapes around. I have a
professor that needs a similar model created. What can I use
softwarewise to develop something like these. I've never used java but
can learn fast through example. Can you point me to any advice or
examples that would help me make something like the models on the site
below? I appreciate any help very much.

http://mathworld.wolfram.com/Tetrahedron.html
 
 
Real Gagnon





PostPosted: 2004-11-10 10:09:00 Top

java-programmer >> Java Newbie question email***@***.com (ryan) wrote in news:a7fdaa26.0411091716.6502a832
@posting.google.com:

> I need some advice on how to develop somethng. The site below has some
> java applets that allow you to move some 3-d shapes around.

Check in the demo\Applets\WireFrame directory in your installation of the
JDK.

Bye.
--
Real Gagnon from Quebec, Canada
* Looking for Java or PB snippets ? Visit Real's How-to
* http://www.rgagnon.com/howto.html
 
 
Andrew Thompson





PostPosted: 2004-11-10 14:48:00 Top

java-programmer >> Java Newbie question On 9 Nov 2004 17:16:56 -0800, ryan wrote:

> http://mathworld.wolfram.com/Tetrahedron.html

As an aside, they use an Applet written by Martin Kraus
known as LiveGraphics3D, you can find the homepage here..
<http://wwwvis.informatik.uni-stuttgart.de/~kraus/LiveGraphics3D/>
while some of my own 3D models can be viewed here..
<http://www.1point1c.org/model/index.jsp>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
 
Sean Murphy





PostPosted: 2006-3-7 11:43:00 Top

java-programmer >> Java Newbie question I am just getting started with Java, and come from a background in Microsoft
languages ... I am having a grand ole time with all of the Java Lingo. How
do I sort out all of the acronyms ... J2EE, J2SE, J2ME, servlets, applets,
etc., etc. Or does this just come with time???


 
 
Tail_Spin





PostPosted: 2006-3-7 12:13:00 Top

java-programmer >> Java Newbie question I've found two of the best resoures for me (relative newbie) are google and
the sun java site http://java.sun.com/.


"Sean Murphy" <email***@***.com> wrote in message
news:Mi7Pf.9738$eP4.6974@trnddc05...
> I am just getting started with Java, and come from a background in
Microsoft
> languages ... I am having a grand ole time with all of the Java Lingo. How
> do I sort out all of the acronyms ... J2EE, J2SE, J2ME, servlets, applets,
> etc., etc. Or does this just come with time???
>
>


 
 
ram





PostPosted: 2006-3-7 12:21:00 Top

java-programmer >> Java Newbie question "Sean Murphy" <email***@***.com> writes:
>I am just getting started with Java, and come from a background
>in Microsoft languages ... I am having a grand ole time with
>all of the Java Lingo. How do I sort out all of the acronyms
>... J2EE, J2SE, J2ME, servlets, applets,

Don't worry! For the beginning it is entirely sufficient to
know about (in addition to the terms you already have
mentionend) Ant, AntLR, Anvil, AWT, BCEL, Beans, Beanshell,
BlueJ, CoCoon, derby, Dolphin, DOM, Echo, Eclipse, Hibernate,
hsqldb, IntelliJ, iText, J2ME, Jakarta, JavaDoc, JBoss,
JBuilder, JDBC, JDK, JFC, JGoodies, JNI, JNLP, JSF, JSP,
Jucas, JUnit, JVM, Lopica, Maven, Maverick, Midlet, Mustang,
NetBeans, SAX, Spring, Struts, Swing, Tapestry, Tomcat,
Torque, Turbine, UI-delegates, Verge, SOAP, WSDL, UDDI,
JavaBeans, JAXP, JAX-RPC, SAAJ, JAXR, Tag Libraries, JSTL,
Enterprise Java Beans, JAR, JTA, JNDI, JMS, JDOM, dom4j, and
Java Webstart.

To get the meaning, you can read google, sun or mindprod.com.

Just write the buzzword on a file card and its meaning on the
other side and then learn whenever you have some time to
spare.

 
 
Amfur Kilnem





PostPosted: 2006-3-7 12:52:00 Top

java-programmer >> Java Newbie question
"Sean Murphy" <email***@***.com> wrote in message
news:Mi7Pf.9738$eP4.6974@trnddc05...
>I am just getting started with Java, and come from a background in
>Microsoft
> languages ... I am having a grand ole time with all of the Java Lingo. How
> do I sort out all of the acronyms ... J2EE, J2SE, J2ME, servlets, applets,
> etc., etc. Or does this just come with time???
>

Go here...
http://java.sun.com/developer/onlineTraining/new2java/programming/learn/unravelingjava.html


 
 
Oliver Wong





PostPosted: 2006-3-8 2:14:00 Top

java-programmer >> Java Newbie question "Sean Murphy" <email***@***.com> wrote in message
news:Mi7Pf.9738$eP4.6974@trnddc05...
>I am just getting started with Java, and come from a background in
>Microsoft
> languages ... I am having a grand ole time with all of the Java Lingo. How
> do I sort out all of the acronyms ... J2EE, J2SE, J2ME, servlets, applets,
> etc., etc. Or does this just come with time???

I think the trick most people use can be summarized thus:

When you encounter an ancronym (or term) that you don't know, look it up
(e.g. via Google).

For what it's worth, I program in Java for a living, and there's a
couple of terms in Stefan's post which I don't recognize (and didn't bother
to look up); e.g. Anvil, Jucas, Turbine, etc.

- Oliver

 
 
Roedy Green





PostPosted: 2006-3-8 6:50:00 Top

java-programmer >> Java Newbie question On Tue, 07 Mar 2006 18:14:14 GMT, "Oliver Wong" <email***@***.com>
wrote, quoted or indirectly quoted someone who said :

>
> I think the trick most people use can be summarized thus:
>
> When you encounter an ancronym (or term) that you don't know, look it up
>(e.g. via Google).

with Google try definition:JSE

You can also jcheck the Java glossary. If you find a Java-related one
not there, tell me and there soon will be an entyr.
http://mindprod.com/jgloss/jgloss.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
IchBin





PostPosted: 2006-3-8 11:54:00 Top

java-programmer >> Java Newbie question Sean Murphy wrote:
> I am just getting started with Java, and come from a background in Microsoft
> languages ... I am having a grand ole time with all of the Java Lingo. How
> do I sort out all of the acronyms ... J2EE, J2SE, J2ME, servlets, applets,
> etc., etc. Or does this just come with time???
>
>
If I have acronym I don't know then I use an acronym finder website:
http://www.acronymfinder.com

Once I have a handle on that I can do some serious searching..

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
 
dave





PostPosted: 2007-9-6 23:56:00 Top

java-programmer >> Java Newbie question Hello,

I'm studying Java, and now trying to make sense of the concept of
types.

Would it be correct to say:

a Java type is a classification of what could potentially be bound
to a Java variable

Also, The Java class Class really describes types. Would it have made
more sense to call this class Type instead of Class?

 
 
Jeff Higgins





PostPosted: 2007-9-7 0:05:00 Top

java-programmer >> Java Newbie question
dave wrote:
> Hello,
>
> I'm studying Java, and now trying to make sense of the concept of
> types.
>
> Would it be correct to say:
>
> a Java type is a classification of what could potentially be bound
> to a Java variable
>
> Also, The Java class Class really describes types. Would it have made
> more sense to call this class Type instead of Class?
>
<http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html>


 
 
Mark Space





PostPosted: 2007-9-7 0:38:00 Top

java-programmer >> Java Newbie question dave wrote:

>
> a Java type is a classification of what could potentially be bound
> to a Java variable

This works for me. I also think of type as how the JVM will interpret
any given bit pattern to which the variable is bound.


>
> Also, The Java class Class really describes types. Would it have made
> more sense to call this class Type instead of Class?
>

Hmm, but ints, chars, booleans and all the other primitives are also
types, but I don't think that Class describes them. Class only deals
with Java objects (most of the language, admittedly) but there are a few
types it doesn't abstract.

Also, generics are a type, but their type gets erased during
compilations. I don't think Class can represent the un-erased type.
 
 
Patricia Shanahan





PostPosted: 2007-9-7 1:05:00 Top

java-programmer >> Java Newbie question Mark Space wrote:
> dave wrote:
>
>>
>> a Java type is a classification of what could potentially be bound
>> to a Java variable
>
>
> This works for me. I also think of type as how the JVM will interpret
> any given bit pattern to which the variable is bound.
>
>
>>
>> Also, The Java class Class really describes types. Would it have made
>> more sense to call this class Type instead of Class?
>>
>
> Hmm, but ints, chars, booleans and all the other primitives are also
> types, but I don't think that Class describes them. Class only deals
> with Java objects (most of the language, admittedly) but there are a few
> types it doesn't abstract.

Each of the wrapper types has a public static final TYPE field that
references the Class object for the corresponding primitive. For example:

"public static final Class<Integer> TYPE
The Class instance representing the primitive type int."

in class Integer. Class objects for primitives are important in some
reflection interfaces.

>
> Also, generics are a type, but their type gets erased during
> compilations. I don't think Class can represent the un-erased type.

I'm not sure generics count as a type, or anything else, in a running
program. They are effectively a form of compile-time assertion that
enables some extra checking.

Patricia