About 1,710,000 results
Open links in new tab

Got it, one moment

...
Feedback
AI generated code. Review and use carefully. More info on FAQ.
  1. java - How to get a string from another class? - Stack Overflow

    I want to get a string from one class that i set the variable before going into the second class and allow me to use it as a string in this class. Basically there's a String called LastName that i want to use in another class.

    • Reviews: 3
      Usage example
      String lastName;
    • java - How to call a string from another class - Stack Overflow

      Dec 30, 2013 · create a static string variable and assign senderNum to it. Use this static string from another class –

      • Reviews: 4
      • In Java, Can we call the main() method of a class from another …

        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[]

        • Estimated Reading Time: 3 mins
        • How to Call a Method in Another Class in Java - Delft …

          Feb 2, 2024 · Call a public Method in Another Class in Java. A method declared as the public is available for outside access and can be called into another …

        • Accessing a toString method in another class. : r/javahelp - Reddit

          You'll need to create a String[] array in your Songs.java class like so: private String[] array; Now in the constructor add something like this: this.array = new String[] {title, artist, String.valueOf(length)}; and the getter since our variables are private.. public String[] getArray() { …

        • How to call a method in another class from the main class?

          Either way, to call a method in another class you need to instantiate an instance of that class then call the method: Foo foo = new Foo(); foo.someMethodInFoo(); The only thing your main method should have in it is: new Tic_Tac_Toe(); then you won't need to make all your methods static.

        • How to call a method from another class in Java - Code …

          May 1, 2023 · Know how to call a method from another class in Java! Follow our step-by-step guide to understand object creation, class instantiation, and method invocation.

        • Calling a Method from Another Class in Java - Java Guides

          To call a non-static method from another class, you first need to create an instance (object) of the class to which the method belongs. Let's consider a simple example with two classes: Greeting and MainApp. public void sayHello(String name) { System.out.println("Hello, " + name + "!"); public static void main(String[] args) {

        • How to Call a Java Method From Another Class? - JavaBeat

          Jan 31, 2024 · To call/access a non-static method from another class, first, you need to create the class instance (in the class from where you want to invoke it). Up next, you can call the desired method from another class depending upon its access modifier.

        • A Complete Guide to Calling Methods from External Classes in Java

          Oct 24, 2023 · In this comprehensive guide, we will cover everything you need to know about calling methods from external classes in Java. This includes calling public, protected, private, and static methods. We will look at examples, best practices, and recommendations for designing reusable classes with methods in Java. What is a Method in Java?

        Refresh