[JAVA] How to call classes and methods

Foods method of Food class (Food.java)


public class Food {
  //Move all of the following methods to the Person class

  public static String fruits(String fruitsName) {
    return fruitName;

Main method of Main class (main.java)

Call the fruits method of the Food class in Food.java.


public class Main {
  public static void main(String[] args) {

    Food.printData(Food.fruits("straeberry", "Smith"), 65, 1.75, 80.0);

When calling a method of another class, it is necessary to write the name of the class you want to call before the class name and method name.

Recommended Posts

How to call classes and methods
How to separate words in names in classes, methods, and variables
How to use substring and substr methods
How to call AmazonSQSAsync
How to execute and mock methods using JUnit
How to access Java Private methods and fields
[Java] Generics classes and generics methods
[Ruby] Singular methods and singular classes
Ruby methods and classes (basic)
Java abstract methods and classes
[Ruby] Singular methods and singular classes
How to use StringBurrer and Arrays.toString.
How to use EventBus3 and ThreadMode
How to use equality and equality (how to use equals)
[Rails] Differences between redirect_to and render methods and how to output render methods
How to connect Heroku and Sequel
How to call and use API in Java (Spring Boot)
How to convert LocalDate and Timestamp
How to use class methods [Java]
Java generics (defines classes and methods)
How to use classes in Java?
How to use OrientJS and OrientDB together
How to call Swift 5.3 code from Objective-C
[Java] How to output and write files!
Java programming (classes and instances, main methods)
How to set up and use kapt
How to build SquashTM and how to support Japanese
How to use Java classes, definitions, import
How to find the tens and ones
JAVA learning history abstract classes and methods
[Easy] How to upgrade Ruby and bundler
Note: [Docker] How to start and stop
How to write and explain Dockerfile, docker-compose
How to use @Builder and @NoArgsConstructor together
Classes and instances
How to call libraries such as JQuery and JQuery UI in Liferay 7 / DXP
How to deploy
Functions and methods
JDBC promises and examples of how to write
How to output Excel and PDF using Excella
[Java] How to use FileReader class and BufferedReader class
[Java] How to get and output standard input
[Java] Personal summary of classes and methods (basic)
[Ruby] How to use gsub method and sub method
How to play audio and music using javascript
How to use Segmented Control and points to note
Git and GitHub ~ How to fix common errors ~
How to set up and operate jEnv (Mac)
How to use scope and pass processing (Jakarta)
How to get and study java SE8 Gold
How to build API with GraphQL and Rails
How to execute processing before and after docker-entrypoint.sh
How to find the total score and average score
[Rails] How to get success and error messages
How to build parquet-tools and merge Parquet files
Rails scope anti-patterns and how to eliminate them
Ruby How to convert between uppercase and lowercase
[Java] How to use Calendar class and Date class
[Android 9.0 Pie] Example of how to call strings.xml other than Activity and Fragment
How to call functions in bulk with Java reflection
[Ruby] Classes and instances