Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main Class
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package practica01;
- /**
- *
- * @author Hantack
- */
- public class TokenTest {
- public static void main(String[] args) {
- TokenEjempo clase = new TokenEjempo();
- clase.start();
- clase.show();
- }
- }
- // Secondary Class
- package practica01;
- import java.util.Scanner;
- import java.util.StringTokenizer;
- /**
- *
- * @author Hantack
- */
- public class TokenEjempo {
- Scanner xr = new Scanner(System.in);
- public String cad;
- public void start(){
- System.out.println("Ingresa Nombre");
- String nombre = xr.nextLine();
- System.out.println("Ingresa Apellido");
- String apellido = xr.nextLine();
- System.out.println("Ingresa Edad");
- int edad = xr.nextInt();
- cad = nombre+"*"+apellido+"*"+edad;
- System.out.println("Cadena: "+cad);
- }
- public void show(){
- StringTokenizer tk = new StringTokenizer(cad, "*");
- System.out.println("============="
- + "\nNombre: "+tk.nextToken()+""
- + "\nApellido: "+tk.nextToken()+""
- + "\nEdad: "+tk.nextToken());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement