well i had to store 30 arrays of 30 characters, so my big brain was like "ah yes, make 30 arrays of 30 characters to store everything" until i realized "oh shit i coulda just wrote this to a file"
im making a game with ASCII graphics (figuring everything out myself for the most part). i generate a room made of 30 arrays all containing 30 characters. don't worry theres nothing like to generate it, just 1 30 character default array that gets modified, printed and reused
well i had to store 30 arrays of 30 characters, so my big brain was like "ah yes, make 30 arrays of 30 characters to store everything" until i realized "oh shit i coulda just wrote this to a file"
I don't fully understand your reasoning, but you could write this way cleaner. Also as someone said, use a 2d array
grid[0][0] would get the first item in the first array,
grid[1][5] would get the 6th item in the second array
import java.util.Arrays;
// Wrap this code in a class method
char[][] grid = new char[30][];
char[] horizontalRowTemplate = new char[30];
// fill horizontal row array with @
Arrays.fill(horizontalRowTemplate, '@');
horizontalRowTemplate[15] = ' ';
// Fill your grid with the template
Array.fill(grid, horizontalRowTemplate);
// Just to display the result
System.out.print(Arrays.deepToString(grid));
27
u/[deleted] Sep 01 '21
I have no idea why the fuck someone wrote that, and at this point, i'm a bit scared to ask.
But since curiousity is stronger : do you know why was that thing written in the first place ?
4
u/sweetkatydid Sep 01 '21
What the hell? Why???
15
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 01 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/BlackBearFTW Sep 01 '21
I don't fully understand your reasoning, but you could write this way cleaner. Also as someone said, use a 2d array
grid[0][0]would get the first item in the first array,grid[1][5]would get the 6th item in the second array3
u/ycohui Sep 01 '21
Got confused by arrays and kinda not satisfied due to the offset from 10th array
1
u/Knuffya Sep 01 '21
what is this
1
u/_cmz Sep 01 '21
Why tf would someone write that i'm confused
1
u/vinicius_kondo Sep 01 '21
When your optimizer does not support loop unrolling
1
u/TheRealMandelbrotSet Sep 04 '21
/r/AAAAAAAAAAAAAAAAA