AP Computer Science in Java
  • Introduction
  • Introduction to Programming in Java with Karel the Dog
    • Introduction to Programming with Karel
    • More Basic Karel
    • Java Programs and the Run Method
    • Karel Can't Turn Right
    • Methods in Karel
    • Top Down Design and Decomposition in Karel
    • Commenting Your Code
    • SuperKarel
    • For Loops
    • While Loops in Karel
    • If Statements
    • If/Else Statements
    • Control Structures Example
    • How To Indent Your Code
  • Basic Java
    • Printing in Java
    • Variables and Types
    • User Input
    • Arithmetic Expressions
    • Casting
    • Booleans
    • Logical Operators
    • Comparison Operators
    • For Loops
    • While Loops
    • If Statements
    • Loop-and-a-Half
    • Short-Circuit Evaluation
    • De Morgan's Laws
    • Strings
  • Methods
    • Java Methods
    • Methods and Parameters
    • Methods and Return Values
    • Javadoc and More Methods
    • Strings Methods
    • Strings and Characters
    • Exceptions
    • String Processing
  • Classes and Object-Oriented Programming
    • Introduction To Classes and Objects
    • Classes vs. Objects
    • Using a Class as a Client
    • Writing Classes
    • Writing Classes and Instance Methods
    • Getter and Setter Methods
    • Class Methods and Class Variables
    • Method Overloading
    • Local Variables and Scope
    • Key Terms for Classes
    • Objects vs Primitives
    • Inheritance
    • Class Design and Abstract Classes
    • Polymorphism
    • Interfaces
  • Data Structures
    • What Are Data Structures?
    • Introduction to Arrays
    • Using Arrays
    • ArrayList Methods
    • Arrays vs ArrayLists
    • 2D Arrays (Matrices or Grids)
    • Hashmaps
  • Algorithms and Recursion
    • What is an Algorithm?
    • Pseudocode
    • Linear Search
    • Binary Search
    • Selection Sort
    • Insertion Sort
    • Advanced: Recursion
    • Mergesort
Powered by GitBook
On this page
  • Javadoc Rules
  • More Examples

Was this helpful?

  1. Methods

Javadoc and More Methods

Javadoc is all about commenting your code correctly. Javadoc is both a tool and the style of commenting your Java programs. Commenting is important as it provides notes in our code to help others understand it.

Javadoc Rules

Javadoc comments are similar to multiline comments, but contain an extra *. Here is an example of a Javadoc comment and its structure:

/**
 * Description of method
 *
 * @param paramName1  description
 * @param paramName2  description
 * return  Description of return value
 */

More Examples

Here are some examples of proper Javadoc comments:

 /**
  * This method returns the product of two integers.
  *
  * @param numOne  The first integer
  * @param numTwo  The second integer
  * @return  The product of the two integers
  */
 private int product(int numOne, int numTwo)
 {
    return numOne * numTwo;
 }

 /**
  * This method returns an array with each word from a string in it.
  *
  * @param input  The string we want to split.
  * @return  The new string array.
  */
  private String[] split(string input)
  {
    return input.split("\\s+");
  }
PreviousMethods and Return ValuesNextStrings Methods

Last updated 5 years ago

Was this helpful?