Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Talk:Java Programming/Understanding a Java Program

Page contents not supported in other languages.
Add topic
From Wikibooks, open books for an open world
<Talk:Java Programming
Latest comment:15 years ago by Mattylaws in topicFriendly to Newcomers

In later modules, we can do more advanced enhancements of this basic program:

  • put this in a package,org.wikibooks.java.distance, instead of the default package0% developed  as of Jan 28, 2006
  • Change the type ofa,b fields to java.awt.Point2D0% developed  as of Jan 28, 2006
  • Overload the constructor with a Distance(Point2D, Point2D) constructor0% developed  as of Jan 28, 2006
    • first constructor calls this((Point2D, Point2D)0% developed  as of Jan 28, 2006
    • copy arguments defensively since Point/Point2D are mutable.0% developed  as of Jan 28, 2006
  • Change Point to Point2D.Double and change the constructor to take doubles not ints and change main to parse doubles not ints.0% developed  as of Jan 28, 2006
  • define a new Point3D interface (extends Point2D) and Point3D.Double (extends Point2D.Double?)0% developed  as of Jan 28, 2006class to show how the Distance program can work with other Points
  • Add exception handling around the String->number parsing and array indexing in main0% developed  as of Jan 28, 2006
  • use number formats for the points, distance0% developed  as of Jan 28, 2006
  • use internationalization/resource bundles for the text, number formats0% developed  as of Jan 28, 2006

--djb18:26, 28 January 2006 (UTC)Reply

Friendly to Newcomers

[edit source]

Could this example be a bit confusing to newbies to the language? --Mattylaws (talk)12:44, 10 March 2010 (UTC)Reply

Questions

[edit source]

How do you use the distance program in eclipse? It isn't obvious how points can be entered the command prompt seems unresponsive.

error

[edit source]
jc@JCMAIN:~/java$ javac Distance.java Distance.java:1: 'class' or 'interface' expected{^1 error

- Any ideas?161.112.83.10210:40, 7 October 2007 (UTC)Reply

This didn't compile for me until I changed:

...

privatestaticintintValue(Stringdata){returnInteger.parseInt(data);}}

To:

privatestaticintintValue(Stringdata){returnjava.lang.Integer.parseInt(data);}}

That said I really don't know what I'm doing here, and just got the idea to try that off of some random googling. Should the page be changed, or maybe there's a better fix. --Keithonearth (talk)19:09, 21 August 2009 (UTC)Reply

Retrieved from "https://en.wikibooks.org/w/index.php?title=Talk:Java_Programming/Understanding_a_Java_Program&oldid=2449488"
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp