没有对象的调用方法 [英] Calling method without object

查看:113
本文介绍了没有对象的调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为自己构建了一个小的(只有3个方法!)api,我希望能够像调用Powerbot中的方法一样调用它(一个Runescape botting工具(我用它,但用于编程)目的,不是为了实际的作弊目的)),而不创建你需要的文件的对象。我怎么能这样做?

I have built a small (and 3 methods only!) api for myself, and I want to be able to call it like how you would call a method in Powerbot (A Runescape botting tool (I use it, but for programming purposes, not for actual cheating purposes)), without creating an Object of the file you'd require. How would i be able to do this?

推荐答案

如果在导入类时使用static关键字,则可以使用其方法好像他们属于你要导入他们的班级。请参阅:

If you use the static keyword when importing your class, you can use its methods as if they belong to the class you're importing them to. See:

http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html

当然,你的api方法也必须是静态的。

And of course your "api methods" need to be static as well.

这篇关于没有对象的调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆