xFactorSchool.com
Python
JavaScript
How to Do Examples
C 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 Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
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; } }