在Codenameone中使用分割方法时出错 [英] Error using split method in Codenameone

查看:75
本文介绍了在Codenameone中使用分割方法时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的Codenameone项目。它包含以下代码:

I have created a new Codenameone project. It contains the following code:

String values = "one, two, tree";
String[] v = values.split(",");

当我构建项目时,出现此错误:

When I build the project, I got this error:

location: variable definition of type String 
error: cannot find symbol
String[] v = values.split(",");
symbol:   method split(String)

但是,如果我使用示例项目 MapsDemo并使用split方法,则一切正常。

However, if I take the sample project "MapsDemo" and use the split method, everything is ok.

可以做什么

谢谢。

推荐答案

代号一个支持Java 5和 String.split()的子集不存在。在所有平台上更改VM实现代码要比在一个包空间的代号中添加一个可移植库要困难得多。使所有边缘情况都100%兼容也变得更加困难,并且使可执行文件更大(即使您不使用它,也要为String.split付费!)。

Codename One supports a subset of Java 5 and String.split() isn't there. Its much harder to change the VM implementation code across all platforms than just add a portable library in the codename one package space. Its also harder to make all the edge cases 100% compatible and it makes the executable larger (you pay for String.split even if you don't use it!).

我们有 StringUtils StringTokenizer ,在 cn1lib 部分。

这篇关于在Codenameone中使用分割方法时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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