nested for loop for alphabet increment


I have searched everywhere and I cannot figure out how to create this output using a nested for loop in java:





continued until z

this is what I have tried

String alphabet = "abcdefghijklmnopqrstuvwxyz";

for(int i = 0; i <= 25; i++) { for(char j = (char)(alphabet.charAt(i)); j<=i; j++) { System.out.print(j); } System.out.println(); }

Please help me!


Here is the answer:

for (int x = 'a'; x<='z'; x++) { for (int i = 'a'; i<=x; i++) { System.out.print((char)i); } System.out.println(); }

The outer loop switches from one row to another whilst the inner loop prints the characters for that particular row.


Here you go !


print capital Alphabet

</blockquote> public class Main { public static void main(String[] args) { int i, j; for(i = 1; i<=26; i++) { for(j = 1; j <= 1-i; j++) { System.out.print(" "); for(j = 1; j <= i; j++) System.out.print((char)(char)(i+64)+" "); System.out.println(); //for line break } } }


  • SQLite in operator in query()
  • Remove trailing character(s) from string in Javascript
  • Java add chars to a string
  • Why LongWritable (key) has not been used in Mapper class?
  • all valid combinations of n-pair of parenthesis
  • The time complexity for a code segment
  • PinnedHeaderListView scrolling and header issues
  • To split a string and to check if they are anagram to each other
  • Using Dr.Java, why does ♂ equal something different in the interaction pane than when programmed
  • Waiting for frame creation
  • Finding the intersection between two list of string candidates
  • SQL error syntax 1064 [duplicate]
  • Regex for string splitting not working properly
  • Dijkstra adjacency list
  • Looping in ArrayLists with a Method
  • load an ad (div) just once on first load
  • remove Niqqud from string in javascript
  • java use Regular Expressions to generate a string [duplicate]
  • Greek letters in a GUI - PYTHON
  • Layout design help Android
  • AES padding and writing the ciphertext to a disk file
  • Convert array of 8 bytes to signed long in C++
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • align graphs with different xlab
  • Return words with double consecutive letters
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • LevelDB C iterator
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Reading document lines to the user (python)
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal