Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Arquivo Questao2.java:
- public class main {
- public static void main(String[] args) {
- String temp = null;
- temp = Inversor.inverterString(temp);
- System.out.println(temp);
- System.out.println(Inversor.inverterString("professor"));
- }
- }
- -----------------
- Arquivo Inversor.java
- public class Inversor {
- public static String inverterString(String texto) {
- String reverse = "";
- if (texto != null && !texto.isEmpty()) {
- for(int j = texto.length() - 1; j >= 0; j--) {
- reverse = reverse + texto.charAt(j);
- }
- }
- return reverse;
- }
- }
- ----
- a) retorna uma string vazia;
- b) retorna rosseforp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement