Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Number-only array arguments print one element per line

Open
#1,114 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java

Research direction

Start by locating the Java printer logic and tests for array formatting; the issue does not name specific files or test entry points. Reproduce the examples with print width 80, then check how number-only arrays are laid out both as a final argument and when they fit on one line. Done means short arrays stay on one line and longer arrays wrap elements across lines without dropping commas.

Written by the indexing model from the issue text.

Description

Prettier-Java 2.11.0

# Options (if any):
--print-width 80

Input:

class A {
  void f() {
    assertEquals(Bytes.fromInt(0x01020304), new byte[] { 0x01, 0x02, 0x03, 0x04 });
    community = fromExtended(0x02, new byte[] { 0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64 });
  }
}

Output:

class A {

  void f() {
    assertEquals(Bytes.fromInt(0x01020304), new byte[] {
      0x01,
      0x02,
      0x03,
      0x04,
    });
    community = fromExtended(0x02, new byte[] {
      0x00,
      0x00,
      0x00,
      0x64,
      0x19,
      0x00,
      0x00,
      0x00,
      0x00,
      0x64,
      0x19,
      0x00,
      0x00,
      0x00,
      0x00
      0x64,
    });
  }
}

Expected behavior:

class A {

  void f() {
    assertEquals(
      Bytes.fromInt(0x01020304),
      new byte[] { 0x01, 0x02, 0x03, 0x04 }
    );
    community = fromExtended(
      0x02,
      new byte[] {
        0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00,
        0x00, 0x00, 0x00, 0x64,
      }
    );
  }
}

This matches Prettier JS, which doesn't hug a number-only array as the last argument and fills its elements across lines:

community = fromExtended(
  0x02,
  [
    0x00, 0x00, 0x00, 0x64, 0x19, 0x00, 0x00, 0x00, 0x00, 0x64, 0x19, 0x00,
    0x00, 0x00, 0x00, 0x64,
  ],
);

2.8.1 also kept short arrays like the first one on a single line:

assertEquals(Bytes.fromInt(0x01020304), new byte[] { 0x01, 0x02, 0x03, 0x04 });
Dominant language
Java
Stars
1.2k
Forks
123
Avg merge
2d 10h
Merged PRs (30d)
35

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jhipster/prettier-java

All issues in jhipster/prettier-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.