如何在Java中将列表转换为数组?
//code in C#
List<int> sep = new List<int>();
sep.Add(1);
sep.Add(2);
sep.Add(3);
Console.WriteLine("\nCapacity: {0}", sep.Capacity);
Console.WriteLine(sep.ToArray());
Run Code Online (Sandbox Code Playgroud) 我想在JList中添加一些文本并对齐它但它不起作用.它没有正确对齐.假设我有两个字符串:String a = "Apple juice is good"; String b = "Fun";使用我的代码后,字符串b仍然更短
while(isOk){
String string = String.format("%-100s",text);
// here i am adding the strings to a JList
menuModel.add(menuList.getModel().getSize(), string + "L");
}
Run Code Online (Sandbox Code Playgroud)