我需要inString
在其他课程中获得变量.我怎样才能做到这一点?
public class main {
public static StringBuffer inString;
public static void main(String[] args) {
inString = new StringBuffer("Our aim is to make a 15 realistic game, where grinding powerlines and doing a tailwhip isn't easy, like in the real world. A game in which you will feel like you're actual riding. A game in which creativity and beauty are combined. ");
inString = new StringBuffer(inString.toString().replaceAll(" +", " "));
}
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试System.out.println(main.inString);
在我的Textcl.class中使用,但得到null
.
我想用第二个char对String数组进行排序,但位置"1"的char索引始终为-1,因此sort不起作用.怎么了?
String[] wordList = outString.toString().split(", ");
for (int i = 0; i < wordList.length; i++) {
int n =wordList[i].indexOf(wordList.toString().charAt(1));
}
Arrays.sort(wordList, 1,0);
for (String str : wordList) {
System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 kotlin 的所有功能,但似乎它们都不起作用,或者可能是我的错。
所以,apply
不String
工作。例子:
val str = someStr.apply {
toUpperCase()
if (contains("W")) replace("W", "w")
}
Run Code Online (Sandbox Code Playgroud)
输入 -> xywz
输出 -> xywz
预期 -> XYwZ
Java风格:
val str = it.text().toString().toUpperCase()
if (str.contains("W")) str.replace("W", "w")
Run Code Online (Sandbox Code Playgroud)
输入 -> xywz
输出 -> XYwZ
预期 -> XYwZ
难道我做错了什么?
Android Google 地图集群图标在缩小时忽略自定义图标。有什么建议如何修复它吗?
override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
mClusterIconGenerator.setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
mClusterIconGenerator.setTextAppearance(R.style.WhiteTextAppearance)
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
Run Code Online (Sandbox Code Playgroud)