Bookmark Topic Watch Topic
  • New Topic
friki data migration
Ranch Hand
Posts: 772
  • Likes 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Frequently Asked Questions in the Beginning Java Forum

  • How do I fix the compile-time error "Cannot make static reference to the non-static method name() in type class"?
  • What's the difference between equals() and the == operator?
  • Why doesn't Scanner.nextLine() work? I thought it would stop and wait for me to enter something but it doesn't. (If you're so inclined, you can read a longer explanation here)

  • Other common questions:

    What should every Java greenhorn know?

    (For more advanced topics, check out the Java-FAQ.)

  • What does a Java program look like?
  • How do I run my very first Java program?
  • Got no money for books so how can I learn Java?
  • I want to buy a couple of books about Java. What do you recommend?
    • Browse through JavaRanch's book reviews. If you see a book that satisfies your needs a simple click will take you straight to where you can order it.
  • Where is the Java API?
  • What non-Windows Support is there for Java?
  • What's a JAR file, and how do I make it executable?
  • How do I make an .exe of my Java program?
    • Maybe using executable JarFiles would be more appropriate. See the MacOsxFaq for hints on how to build a double-clickable OS X application.
    • JWrapper creates native Windows, Linux and OSX apps.
  • Classpath, what is it and how do I set it?
  • What is a Singleton?
  • What is threading or multi-threading?
  • What is an object?
    • It's a thing with state and behavior, of course.
    • It's an instance of a class
    • An object is a User-defined Data Type (UDT).
  • What is the difference between an object and an instance?
  • What is a class?
    • A class is the definition of some object data type.
    • Class is the basic building block of an object oriented system.It is a an entity which acts as a data type and also shows behaviour.A class can have attributes and functions of its own.Thus it can act on messages and also maintain its state.
  • What's the difference between a static field and an instance field?
    • Instance fields belong to objects (which are instances of a class) with each object having its own copy.
    • Static fields belong to a class, and we all know there's only one of each class, so there's only one copy of each static field.
    • Static variables are initialized at the class load time, instance variables are initialized before a constructor is executed.
  • Can you override a static method?
  • Is Java call-by-reference or call-by-value?
  • What is a JVM? JRE? JDK?
    • A JVM (Java Virtual Machine) is an imaginary (theoretical) machine that executes Java bytecodes.
    • A JRE (Java Runtime Environment) is a software implementation of a JVM and all the standard Java libraries, and other bits and pieces that are needed to make the thing actually work.
    • A JDK (Java Developer's Kit)is the JRE plus tools like the Java compiler, debugger, and other things needed for basic Java development.
    • The diagram on this page visualizes it nicely: JDK and JRE are brackets on the left, while the JVM is the layer at the bottom.
  • How do I clear the console screen?
  • Why is 1.0 - 2.0/3.0 != 1.0/3.0? (and other arithmetic inaccuracies)
    • Arithmetic as done by Java has limits to its accuracy. Some of these have to do with the fact that computer arithmetic is done with base 2, not base 10. Another reason is that 1/3 does not have a finite representation in either base 2 or base 10. You can find a more detailed description here . All the details can be found in the article What Every Computer Scientist Should Know About Floating-Point Arithmetic
    • Java implements exact arithmetic with the JavaDoc:java.math.BigInteger and JavaDoc:java.math.BigDecimal classes. As an aside, calculations involving amounts of money should never be done with floats or doubles, but always with BigDecimal.
    • Another option is to use decimal arithmetic, which avoids the problems caused by binary numbers. More information about that can be found here
  • What are the differences between an interface and an abstract class?
  • Where can I find example code for the XYZ class?
    • Java2s also covers advanced Java APIs and 3rd-party APIs. Even more examples are at Kode Java.
  • What are the differences between the various JDK versions?
    • The documentation of each JDK release contains a page called "New Features and Enhancements" (or similar), which lists the changes from the previous release. You can find links to the documentation of the various releases here. The javadoc page for a class also mentions the JDK version in which it was introduced.
  • I'm having trouble understanding how algorithm XYZ works.
  • How do I work with dates, in particular, convert between dates and strings?
    • The JavaDatesFaq has example code for the most common tasks, as well as links to some further material.
  • What is a compile-time constant?
  • Can I test code without installing anything?
  • How do I override the equals and hashCode methods?
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!