0

in the Kotlin if you out of the class write this code

fun main(){
System.out.println("ali")
}

you can run this method without run emulator. android studio show play icon first the method if you write this code in Kotlin and you can run only this method. I want do it in Androidstudio Java. are you know how do it? thank you

Ali Doran
  • 378
  • 1
  • 12
  • Have you tried putting it in a class? `public class Main { public static void main(String... args) { System.out.println("Hello"); } }` – assylias Apr 12 '21 at 20:37
  • possible duplicate of https://stackoverflow.com/questions/44823064/run-single-kotlin-class-with-main-function-in-android-studio – Narendra_Nath Apr 12 '21 at 20:41
  • 1
    Tip: in Kotlin or Java, if you type `psvm` and hit Enter, it generates this function for you. – Tenfour04 Apr 12 '21 at 22:28

1 Answers1

1

Main in java is:

public class Main {
    public static void main(String... args) {
        //you code here
    }
}

If this solution doesn't work you can use the Junit test case in order to run one specific method

Ali Doran
  • 378
  • 1
  • 12
Luke
  • 516
  • 2
  • 10