小编Pen*_*826的帖子

存储学生详细信息的最佳收藏?

嘿我正在为学生的细节做一个商店,我想要一些关于使用哪个系列的意见.商店将提供姓名,号码,地址和电子邮件等详细信息.然后将商店打印到文本文件,我可以在其中加载,保存,编辑和删除文本文件中的详细信息.我以前从未这样做过,如果在使用集合时对文件I/O有任何限制,我也不会这样做.所以我非常感谢这些评论.提前致谢.

java collections file-io

5
推荐指数
1
解决办法
2507
查看次数

Hashmap的搜索方法

我需要搜索方法的hashmap,我不知道如何做到这一点.我也试图做一个编辑方法,我认为我需要这个方法.我的hashMap用于存储员工数据.我有MainApp,Employee类和一个EmployeeStore类.有人可以帮忙吗?

public class MainApp
{

    public static void main(String[] args)
    {
        new MainApp().start();

    }
    public void start()
    {
        EmployeeStore Store = new EmployeeStore();
        Store.add(new Employee ("James O' Carroll", 18,"hotmail.com"));

        Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com"));

        Store.add(new Employee ("Luis Suarez", 7,"gmail.com"));
        Store.print();
        Store.clear();
        Store.print();

        Store.add(new Employee ("James O' Carroll", 18,"hotmail.com"));

        Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com"));

        Store.add(new Employee ("Luis Suarez", 7,"gmail.com"));

        Store.print();
        Store.remove("Andy Carroll");
        Store.print();


    }

}


//Imports.
import java.util.HashMap;
//********************************************************************
import java.util.Map;

public class EmployeeStore 
{
    HashMap<String, Employee> …
Run Code Online (Sandbox Code Playgroud)

java search hashmap

2
推荐指数
1
解决办法
1080
查看次数

while((Status.health!0)&&(Wolves.health!0))期望表达式")"时出错

嘿,我有一个错误:

while((Status.health !0) && (Wolves.health !0) )
Run Code Online (Sandbox Code Playgroud)

有人能看出这有什么问题吗?

c++ boolean-logic boolean-expression

2
推荐指数
1
解决办法
72
查看次数

java中的连续错误

可能重复:
如何比较Java中的字符串?

在我的Java应用程序中.要接受挑战,请按y,但程序不会继续.谁能帮我这个?

这是我的代码:

import java.util.Scanner;


    public class MainApp 
    {


        public static void main(String[] args)
        {
            Scanner scanner = new Scanner(System.in);
            System.out.println("Hello User");
            System.out.println("Please Enter your first name");
            String name;
            name =scanner.next();

        System.out.println("\n" + " Hello " + name + "how are you today?");
        String y="";
        y=scanner.next();


        System.out.println("\n" + " Well " +  name + " I am " + y + " Too." +"\n" + " I have a riddle for you " + name + ", wll you …
Run Code Online (Sandbox Code Playgroud)

java user-input

1
推荐指数
1
解决办法
86
查看次数

Hashmap覆盖值

嘿我试图为飞机制作一个hashMap商店.但是当我添加时,它只会打印出一个航班.谁能帮我这个.这是我的代码:

import java.util.Scanner;


public class MainApp 
{
    private Scanner keyboard = new Scanner(System.in);
    public static void main(String[] args)
    {
        new MainApp().start();  
    }

    public void start()
    {
        Airline aerLingus = new Airline("AerLingus");
        PlaneStore planeStore = new PlaneStore("Aer Lingus");

        Flight p1 = new Flight("Aer Lingus","A01", 150.5, 10.5, 500, Flight.AIRPLANETYPE.AIRBUS);
        Flight p2 = new Flight("Aer Lingus","B01", 50.3, 1.5, 91, Flight.AIRPLANETYPE.CORPORATE);
        Flight p3 = new Flight("Aer Lingus","C01", 12.2, -3.1, 56, Flight.AIRPLANETYPE.AIRBUS);


        Flight p4 = new Flight("Ryan Air","D01", 10.5, 1.5, 430, Flight.AIRPLANETYPE.PRIVATE);
        Flight p5 = …
Run Code Online (Sandbox Code Playgroud)

java hashmap

1
推荐指数
1
解决办法
6519
查看次数

柜台申请不会停止

我做了一个计数器应用程序,当用户在控制台中输入"stop"时,它使用线程来中断计数.我仔细检查了我的代码,我看不出问题.我是新手,所以任何人都可以看看这个.

import java.util.Scanner;

public class CounterInterruptApp 
{

    public static void main(String[] args) 
    {
      new CounterInterruptApp().start();
    }

    public void start()
    {
        Thread counter = new Counter(); //Instantiate the counter thread.
        counter.start(); //Start the counter thread.

        Scanner scanner = new Scanner(System.in);
        String s = "";
        while(!s.equals("stop")); //Wait for the user to enter stop.
        s=scanner.next();
        counter.interrupt(); //Interrupt the counter thread.
    }

}



public class Counter extends Thread //Extend Thread for the use of the Thread Interface.
{
    public void run()//Run method.  This is …
Run Code Online (Sandbox Code Playgroud)

java multithreading interrupt

0
推荐指数
1
解决办法
485
查看次数

继承不起作用

嘿,我刚刚练习继承,我遇到了一个问题.我在我的汽车类(子类)中得到错误,车辆(父)中的变量不可见.我没有做任何改变这一点,我甚至不知道如何让它隐形.谁能帮我这个.

public class Vehicle 
{
    private String make, model, colour;
    private int registrationNumber;

    public Vehicle()
    {
        this.make = "";
        this.model = "";
        this.colour = "";
        this.registrationNumber = 0;


    }


    public Vehicle(String make, String model, String colour,
            int registrationNumber) 
    {
        this.make = make;
        this.model = model;
        this.colour = colour;
        this.registrationNumber = registrationNumber;
    }


    public String getMake() 
    {
        return make;
    }


    public void setMake(String make) 
    {
        this.make = make;
    }


    public String getModel() 
    {
        return model;
    }


    public void setModel(String model) 
    { …
Run Code Online (Sandbox Code Playgroud)

java inheritance

0
推荐指数
2
解决办法
1162
查看次数