EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

In Java, a method can be defined with a return type and without arguments. This means the method returns a value but does not take any input parameters.

βœ… General Syntax:

returnType methodName() {
// method body
return value; // value must match returnType
}

In Java, methods can be categorized by whether they return a value and whether they accept arguments.

You’re asking for:

Java method with arguments but without return type


βœ… 1. Definition:

These methods:

  • Accept arguments (parameters)

  • Do not return any value

  • Use the keyword void as return type


  • βœ… 2. Syntax Example:

public class Example {

// Method with arguments, no return type
void greetUser(String name) {
System.out.println(“Hello, ” + name + “!”);
}

public static void main(String[] args) {
Example obj = new Example();
obj.greetUser(“Bhagya”); // Calling method with argument
}
}

In Java, a method without a return type and without arguments is:

  • Declared using void (which means no return value)

  • And it does not take any parameters inside the parentheses ()


βœ… Syntax:

void methodName() {
// method body
}

 

 

 

Without a return type and without arguments

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer