Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25260

Re: Nothing prints when I compile my code

Path csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: Nothing prints when I compile my code
Date Sun, 08 Sep 2013 09:50:21 -0700
Organization A noiseless patient Spider
Lines 35
Message-ID <l0i9sg$g9n$1@dont-email.me> (permalink)
References <ec0481dd-6ec3-4ff7-93de-48d577af8fc0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sun, 8 Sep 2013 16:50:24 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="9185b88a2b5381a82810209530bb8295"; logging-data="16695"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+I4EIozJ+l1wFIbgDri+tAaieXSJm+Rys="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To <ec0481dd-6ec3-4ff7-93de-48d577af8fc0@googlegroups.com>
Cancel-Lock sha1:K5JHW5Hs6s4yBEOqF6O3+LiwVpQ=
Xref csiph.com comp.lang.java.programmer:25260

Show key headers only | View raw


On 9/8/2013 9:06 AM, John Stephens wrote:
> Another Homework assignment for College Intro to Java course. I am
> having a disconnect with what the issue is. It compiles fine but does
> not print. Hints anyone?
>

It's because you didn't tell it to print anything.  Look at the code, 
you read the input (call 'nextLine' on the Scanner) before you print 
anything.  I'd suggest you add a prompt before each use of a scanner 
method to give you a hint when the scanner is waiting for input.

Here's an example:

 > public class Homesick
 > {
 > 
//----------------------------------------------------------------------------------------------
 >     // Reads a character string from the user and prints it.
 > 
//----------------------------------------------------------------------------------------------
 >     public static void main (String[] args)
 >     {
 >      String name, college, petname;
 >      int age;
 >      Scanner scan = new Scanner (System.in);
        System.out.println( "Enter your name:" );   // add this
 >      String Name = scan.nextLine();
 >
 >      System.out.println ("Johnny");


Then you will see some output before the program waits.  Add an 
appropriate println before each use of a scanner method and the program 
will be easier to use.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Nothing prints when I compile my code John Stephens <johnnyringo888@gmail.com> - 2013-09-08 09:06 -0700
  Re: Nothing prints when I compile my code markspace <markspace@nospam.nospam> - 2013-09-08 09:50 -0700
  Re: Nothing prints when I compile my code John Stephens <johnnyringo888@gmail.com> - 2013-09-08 09:55 -0700
  Re: Nothing prints when I compile my code Roedy Green <see_website@mindprod.com.invalid> - 2013-09-09 01:48 -0700

csiph-web