从语言课获取语言 [英] Getting the languages from Language class
本文介绍了从语言课获取语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此非官方的Java Google Translate API,可将文本从一种语言翻译成另一种语言.
I use this Unofficial Java Google Translate API to translate a text from a language to another language.
我有一个Language
类,其中包含所有语言名称,如下面的图像所示:
I have Language
class that contains the all language names like in the image bellow:
我想要一个包含语言名称的数组. 我该怎么办?
I want to get an array with the languages names. How can I do this?
如果是C#,我会这样做:
If it would be C# I would do this:
PropertyInfo[] languages;
languages = typeof(Language).GetProperties();
推荐答案
您可以使用以下所有字段
You can get all the fields with
Field[] fields = Language.class.getDeclaredFields();
for(Field field: fields)
if (field.getType() == String.class)
System.out.println(field.getName() + " = " + field.get(null));
这篇关于从语言课获取语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文