5 Replies - 2432 Views - Last Post: 19 February 2012 - 07:33 PM Rate Topic: -----

#1 213crz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-February 12

HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 06:29 PM

Good Evening,
My husband is in school learning java and I am trying to learn on my own so that I can help him. I am using jGrasp while doing the examples provided in the book "JAVA IN EASY STEPS," but unfortunately I have come to a problem. I have been looking on line for hours and nothing has resolved this issue. Is it because I'm using jGrasp? If anyone could tell me what I am doing wrong I would greatly appreciate it. You will helping two people! Below is the code and compile error.

import java.text.NumberFormat;
import java.text.SimpleDateFormat;

class Formats
{
	public static void main (String[] args)
	{
	NumberFormat nf= new NumberFormat.getNumberInstance();
	System.out.print("\nNumber: "+nf.format(123456789));
	
	NumberFormat ct=new NumberFormat.getCurrencyInstance();
	System.out.print("\nCurrency: "+ct.format(1234.50f));
	
	NumberFormat pf=new NumberFormat.getPercentInstance();
	System.out.print("\nPercent: "+pf.format(0.75f));
	
	java.util.Calender cal=java.util.Calender.getInstance();
		
	SimpleDateFormat df=new SimpleDateFormat("M/d/y");
	System.out.print("\nDate: "+df.format(ca.getTime()));
	
	SimpleDateFormat tf=new SimpleDateFormat("H:m");
	System.outprint("\nTime: "+tf.format(cal.getTime()));
	}
	
}


COMPILE ERROR


----jGRASP exec: javac -g Formats.java

Formats.java:10: error: cannot find symbol
	NumberFormat nf= new NumberFormat.getNumberInstance();
	                                 ^
  symbol:   class getNumberInstance
  location: class NumberFormat
Formats.java:13: error: cannot find symbol
	NumberFormat ct=new NumberFormat.getCurrencyInstance();
	                                ^
  symbol:   class getCurrencyInstance
  location: class NumberFormat
Formats.java:16: error: cannot find symbol
	NumberFormat pf=new NumberFormat.getPercentInstance();
	                                ^
  symbol:   class getPercentInstance
  location: class NumberFormat
Formats.java:20: error: cannot find symbol
	java.util.Calender cal=java.util.Calender.getInstance();
	         ^
  symbol:   class Calender
  location: package java.util
Formats.java:20: error: cannot find symbol
	java.util.Calender cal=java.util.Calender.getInstance();
	                                ^
  symbol:   class Calender
  location: package java.util
Formats.java:26: error: cannot find symbol
	System.out.print("\nDate: "+df.format(ca.getTime()));
	                                      ^
  symbol:   variable ca
  location: class Formats
6 errors

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.



Any help would be greatly appreciated

This post has been edited by blackcompe: 19 February 2012 - 06:37 PM


Is This A Good Question/Topic? 0
  • +

Replies To: HELP-A-NOOB: "Cannot find symbol"

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 06:37 PM

1. getNumberInstance is a static method. Don't create an instance to call it. It's simply:

NumberFormat nf = NumberFormat.getNumberInstance();


Same goes for the other static factory methods, e.g. getXXXInstance.

2. It's Calendar. That's why it's not found in java.util.

3.

System.out.print("\nDate: "+df.format(ca.getTime()));



ca isn't a variable, but cal is.
Was This Post Helpful? 0
  • +
  • -

#3 213crz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-February 12

Re: HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 06:48 PM

Thanks So much. It worked! Just to clarify 231crz is my husband and I am, Daisy (a woman) trying to learn java as well. I am the one with the questions, since he is very new to this as well. Thanks again for all your help!

Daisy
Was This Post Helpful? 0
  • +
  • -

#4 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 06:49 PM

Glad I could help. :^:
Was This Post Helpful? 0
  • +
  • -

#5 213crz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-February 12

Re: HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 07:10 PM

I have another question if you don't mind. I am trying to figure out what the difference is between "system.out.print" and "system.in.print."

This is my understanding of it.
System.out.print is what we tell the computer to spit out a certain statement
System.in.print is us telling the computer to spit the out the statement after clicking. Is that correct?

Thanks
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10444
  • View blog
  • Posts: 38,682
  • Joined: 27-December 08

Re: HELP-A-NOOB: "Cannot find symbol"

Posted 19 February 2012 - 07:33 PM

There is no System.in.print(), since System.in is an InputStream. See the documentation.
http://docs.oracle.c...nputStream.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1