public class Word { private char[] tab; private int pole = 0; public Word() { tab = new char[100]; for (int i = 0; i < tab.length; ++i) { tab[i] = 0; } } public void addChar(char add) { tab[pole] = add; pole++; } public void show() { for (int i = 0; i < tab.length; ++i) { if (tab[i] == 0) { break; } else { System.out.print(tab[i] + " "); } } } public int length(){ int k=0; for(int i=0; i <= tab.length; i++){ if(tab[i] == 0) break; else{ k++; } } return k; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter