xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a method in a class in Java
Java Online Editor
Execute Code
More Java Sample Codes
public class ExampleApp { public static void main(String[] args) { Math mathObj = new Math(); // object of Math class // Calling the method and assigning the return value to sumVariable int sumVariable = mathObj.addNumber(10, 20); System.out.println("The sum of 10 and 20 is " + sumVariable + "."); } } // This is a class class Math { //This is a method of the class public int addNumber(int x, int y) { return x + y; } }