小编Toe*_*fen的帖子

Java 如何将字符串数组中的所有字符合并到一个新字符串中?

我在做一个方法

public static String merge(String... s)
Run Code Online (Sandbox Code Playgroud)

这是输入:

String a = merge("AM ","L","GEDS","ORATKRR","","R TRTE","IO","TGAUU");
System.out.println(a);
Run Code Online (Sandbox Code Playgroud)

预期输出:

ALGORITMER OG DATASTRUKTURER
Run Code Online (Sandbox Code Playgroud)

我尝试多次运行循环,以便它选取 s[0].charAt(index) 并将其附加到字符串以进行输出。我遇到的问题是,当我尝试运行 s[1].charAt(1) 的循环时,它为空,我希望它不会得到 StringIndexOutOfBoundsException,而是继续 s[2] 并附加 s[2]。字符到字符串。

我该怎么做?

java arrays algorithm data-structures

3
推荐指数
1
解决办法
205
查看次数

Android QR 位图需要帮助来删除边距

我已将字符串编码为 QR 位图。图片就变成了这样:

QR 位图图像

我需要更改什么才能使 QR 周围没有空格?我尝试阅读有关 MultiFormatWriter() 和 setPixels() 的文档,但找不到错误所在。这是代码:

Bitmap encodeAsBitmap(String str) throws  WriterException {
    BitMatrix result;
    try {
        result = new MultiFormatWriter().encode(str,
                BarcodeFormat.QR_CODE, 500, 500, null);
    } catch (IllegalArgumentException iae) {
        return null;
    }

    int w = result.getWidth();
    int h = result.getHeight();
    int[] pixels = new int [w * h];
    for (int i = 0; i < h; i++) {
        int offset = i * w;
        for (int j = 0; j < w; j++) {
            pixels[offset + …
Run Code Online (Sandbox Code Playgroud)

java android pixel bitmap

2
推荐指数
1
解决办法
1281
查看次数

标签 统计

java ×2

algorithm ×1

android ×1

arrays ×1

bitmap ×1

data-structures ×1

pixel ×1