开发者

Access functions from anywhere in the program-Android

开发者 https://www.devze.com 2023-02-21 08:35 出处:网络
I\'m starting to work with the android system an开发者_开发知识库d Java in general. I\'m coming from a VB background, and in VB I had a Module, that enabled me to write functions that were accessible

I'm starting to work with the android system an开发者_开发知识库d Java in general.

I'm coming from a VB background, and in VB I had a Module, that enabled me to write functions that were accessible from everywhere in my program(different pages for example)

Is there something similar to the Module of VB6 in Java and Android?

Thanks!


In Java you can set the visibilty of a function to public. Then you can access it from everywhere in your code, if you have a object of that class.

public void doSomething() {
}

Then you can also use the keyword static to define methods that do not need to be called from an object of that class but exists during the first loading of the class until the end of the programm:

public static void doSomething() {
}
0

精彩评论

暂无评论...
验证码 换一张
取 消