File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
src/module3/arrayslist/generics Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ package module3 .arrayslist .generics ;
2+
3+ public class GuardadorDeString {
4+
5+ private String [] nomes ;
6+ private int posicaoLivre ;
7+
8+ public GuardadorDeString () {
9+ this .nomes = new String [10 ];
10+ this .posicaoLivre = 0 ;
11+ }
12+
13+ public void adiciona (String nome ) {
14+ this .nomes [this .posicaoLivre ] = nome ;
15+ this .posicaoLivre ++;
16+ }
17+
18+ public int getQuantidadeDeElementos () {
19+ return this .posicaoLivre ;
20+ }
21+
22+ public String getReferencia (int posicao ) {
23+ return this .nomes [posicao ];
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package module3 .arrayslist .generics ;
2+
3+ public class TestaGuardador {
4+
5+ public static void main (String [] args ) {
6+
7+ GuardadorDeString guardadorDeString = new GuardadorDeString ();
8+
9+ String nome = new String ("emanoel" );
10+ guardadorDeString .adiciona (nome );
11+
12+ String sobrenome = new String ("campos" );
13+ guardadorDeString .adiciona (sobrenome );
14+
15+ int tamanho = guardadorDeString .getQuantidadeDeElementos ();
16+ System .out .println (tamanho );
17+
18+ String ref = guardadorDeString .getReferencia (0 );
19+ String ref2 = guardadorDeString .getReferencia (1 );
20+
21+ System .out .println (ref .length ());
22+ System .out .println (ref2 .toUpperCase ());
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments