开发者

How to compare string values of CharSequence[]?

I have the following CharSequence defined:

final CharSequence[] videoQualities = {"an开发者_运维知识库y", "medium", "high", "hd"};

I am getting two string values: availableQuality and requestedQuality. Both can contain values from the CharSequence above only.

How can I check if availableQuality more or equal to requestedQuality?


Try using an ArrayList instead of CharSequence[]. You can then use ArrayList.indexOf() to return a numeric index that you can use to compare position in the ArrayList.


Enum to rescue.

define videoQualities as enum

public enum VideoQualities { any, medium, high, hd }

VideoQualities availableQuality; VideoQualities requestedQuality;

if (availableQuality.ordinal() >= requestedQuality.ordinal()) { .... }

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜