JavaRanch Home    
 
This page:         last edited 04 October 2013         What's Changed?         Edit

Java Beginners Faq   

What should every Java greenhorn know?

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

  1. What does a Java program look like?
  2. How do I run my very first Java program?
  3. Got no money for books so how can I learn Java?
  4. 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.
  5. Where is the Java API?
  6. What non-Windows Support is there for Java?
  7. What's a JAR file, and how do I make it executable?
  8. 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.
  9. Classpath, what is it and how do I set it?
  10. What is a Singleton?
  11. What is threading?
  12. 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).
  13. What is the difference between an object and an instance?
  14. 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.
  15. 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 (added by - Kunal Jaggi).
  16. Can you override a static method?
  17. Is Java call-by-reference or call-by-value?
  18. What is a JVM? JRE? JDK? J2SDK?
    • 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) or J2SDK (Java 2 Software Developer's Kit) are two different names for the same thing: a 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 blue layer at the bottom.
  19. How do I clear the console screen?
  20. 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
  21. What are the differences between an interface and an abstract class?
  22. Where can I find example code for the XYZ class?
    • The Example Depot has lots of commented examples. Java2s also covers advanced and 3rd-party APIs. And some more examples from Kode Java website.
  23. 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.
  24. I'm having trouble understanding how algorithm XYZ works.
  25. 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.
  26. What is a compile-time constant?
  27. Can I test code without installing anything?
  28. How do I override the equals and hashCode methods?


CategoryFaq

JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton