About 32,400,000 results
Open links in new tab
  1. Passing arguments in main method in java class - Stack Overflow

    Nov 22, 2010 · Can someone tell me what is the need to declare a class like this: String k; public Test(String a, String b, String c){ k = a + " " + b + " " + c; //do something. public void run(){ System.out.println(k); public static void main(String[] args) { String l = args[0]; String m = args[1]; String n = args[2]; Test obj = new Test(l,m,n); obj.run();

  2. How do I pass a class as a parameter in Java? - Stack Overflow

    Oct 29, 2015 · Is there any way to pass class as a parameter in Java and fire some methods from that class? void main() { callClass(that.class) } void callClass(???? classObject) { classObject.somefunct...

  3. java - Is it possible to call the main method passing args[] from ...

    Nov 8, 2010 · Yes, the main method can be called like any other method, so if you have a class Test with a main method, you can call it from any other class like: Test.main(new String[] { "a", "b" }); and this way you'll pass "a" and "b" as the parameters.

  4. In Java, Can we call the main() method of a class from another class?

    Oct 1, 2024 · It can lead to many errors and exceptions, such as: The main () method must be called from a static method only inside the same class. cannot be referenced. from a static context. mainCaller(); The main () method must be passed the String [] args while calling it from somewhere else. cannot be applied to given types; main(); required: String[]

  5. Parameter Passing Techniques in Java with Examples

    Dec 6, 2022 · There are different ways in which parameter data can be passed into and out of methods and functions. Let us assume that a function B () is called from another function A (). In this case A is called the “caller function” and B is called the “called function or callee function”.

  6. Pass a Class as a Parameter in Java - Baeldung

    Jun 20, 2024 · When working with Java programming, there are situations where we may need to pass a class as a parameter, enabling dynamic behavior and flexibility in our code. In this tutorial, we’ll delve into different approaches for achieving this in Java.

  7. Java main() Method – public static void main(String[] args)

    Apr 11, 2025 · Apart from the above-mentioned signature of main, you could use public static void main(String args[]) or public static void main(String… args) to call the main function in Java. The main method is called if its formal parameter matches that of an array of Strings.

  8. Java main method Explained [Easy Examples] - GoLinuxCloud

    Jan 7, 2024 · Passing arguments to Java main method. Passing arguments to the Java main method is a common way to provide input parameters to a Java application at the time of its execution. These arguments can be used to customize the behavior of the program, specify configuration settings, or provide input data.

  9. Java Main Method - Jenkov.com

    Feb 21, 2020 · This tutorial explains how to create a Java main method in one of your Java classes, so that class can be executed by the Java Virtual Machine.

  10. Java main() Method Explained - Baeldung

    Jan 8, 2024 · To specify which main method the JVM should execute as the entry point of our application, we use the MANIFEST.MF file. Inside the manifest, we can indicate the main class: Main-Class: mypackage.ClassWithMainMethod. This …