首页 > 文档 > join()将字符串加入到字符串数组中
2017
07-20

join()将字符串加入到字符串数组中

Name

join()将字符串加入到字符串数组中

   

Examples

String[] animals = new String[3];

animals[0] = “cat”;

animals[1] = “seal”;

animals[2] = “bear”;

String joinedAnimals = join(animals, ” : “);

println(joinedAnimals); // Prints “cat : seal : bear”

 

// Joining an array of ints requires first

// converting to an array of Strings

int[] numbers = new int[3];

numbers[0] = 8;

numbers[1] = 67;

numbers[2] = 5;

String joinedNumbers = join(nf(numbers, 0), “, “);

println(joinedNumbers); // Prints “8, 67, 5”

Description

Combines an array of Strings into one String, each separated by the character(s) used for the separator parameter. To join arrays of ints or floats, it’s necessary to first convert them to Strings using nf() or nfs().

将一个字符串数组合并为一个字符串, 每一个都由用于分隔符参数的字符分隔。要加入整数或浮点数组, 必须首先使用 nf () nfs () 将它们转换为字符串

Syntax

join(list, separator)

Parameters

list

String[]: array of Strings字符串数组

separator

char: char or String to be placed between each item 在每一个元素中间位置的字符串

Returns

String

Related

split()
trim()
nf()
nfs()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。