Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Number-only array arguments print one element per line

Aperta
#1,114 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 });
Lingua principale
Java
Stelle
1.2k
Fork
122
Merge medio
2g 13h
PR unite (30g)
32

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jhipster/prettier-java

Tutte le issue di jhipster/prettier-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.