猿问

如何解决?我对Java非常陌生

打包应用程序;


导入 java.util.Scanner; 导入 java.util.UUID;


公共类 AccountThis { 私有静态扫描仪扫描仪;


public static void main( String[] args ) {

    //name input

    scanner = new Scanner( System.in );

       System.out.print( "Type your name: " );

        String nameInput = scanner.nextLine();

            System.out.println("Hello" + " " + nameInput);


        //deposit input 

            scanner = new Scanner( System.in );

               System.out.print( "Type how much you want to deposit:" );

                double depositInput = scanner.nextDouble();

                    System.out.println("you want to deposit" + " " + depositInput + "$");



                    public AccountThis(String id) {



                        System.out.println("ID Generated"

                                + "Please Write it down :" + id);





                }



                    class RandomStringUUID {}

                    public id = randID;{


                        UUID randID = UUID.randomUUID();

                        UUID randomUUIDString = randID;

                        System.out.println(randomUUIDString );



                    new AccountThis( nameInput, depositInput, id);

                    }

                    {




                    }

            }





public AccountThis() {

    System.out.println( "created an account." );

}


public AccountThis( String nameInput ) {


    System.out.println( " created account with name " + nameInput );




}



public AccountThis(double depositInput) {


    System.out.println(depositInput + "$" + "added to your account!" );

}



}

我是 Java 新手,我正在尝试获取 id 并将其分配给带有一些文本的控制台,如您所见,如果您能帮我弄清楚,我会失败一点,我会非常高兴


顺便说一句,我称它为 id,因为我整晚都在使用它,但无法弄清楚。


慕盖茨4494581
浏览 125回答 1
1回答

偶然的你

试试这个代码。它工作正常import java.util.Scanner;import java.util.UUID;public class AccountThis {  private static Scanner scanner;  public AccountThis(String nameInput) {    System.out.println(" created account with name " + nameInput);  }  public AccountThis() {    System.out.println("created an account.");  }  public AccountThis(double depositInput) {    System.out.println(depositInput + "$" + "added to your account!");  }  public AccountThis(String nameInput, double depositInput, String id) {    System.out.println(" created account with \n ID : " + id + ", \n name : " + nameInput);    System.out.println(depositInput + "$" + "added to your account!");  }  public static void main(String[] args) {    //name input    scanner = new Scanner(System.in);    System.out.print("Type your name: ");    String nameInput = scanner.nextLine();    System.out.println("Hello" + " " + nameInput);    //deposit input    scanner = new Scanner(System.in);    System.out.print("Type how much you want to deposit:");    double depositInput = scanner.nextDouble();    System.out.println("you want to deposit" + " " + depositInput + "$");    UUID randID = UUID.randomUUID();    String id=randID.toString();    new AccountThis(nameInput, depositInput,id);  }}
随时随地看视频慕课网APP

相关分类

Java
我要回答