我是一名初学者程序员,负责编写库存程序。 目前为止,我只使用BlueJay进行了编程,但我即将学习如何使用vim编辑器。使用BlueJay进行编程时,您不需要编写主要方法。 我很迷茫如何编写主要方法,而我在互联网上研究的所有东西似乎都没有解释或帮助太大。你如何编写一个启动java程序的主要方法?
我已经开始了我有一个库存类和一个Item类的程序的设计。 我将如何开始这个项目?就像我需要用主要方法做什么,以及这将如何工作?
谢谢
这是我到目前为止的代码。
import java.util.*;
public class Inventory
{
private ArrayList<Item>inventory;
/**
* Constructor for objects of class Inventory
*/
public Inventory()
{
inventory = new ArrayList<Item>();
}
/**
* Adds an Item to the Inventory.
*/
public void addItem(String name, int amount, double price, int location)
{
boolean done = false;
if(inventory.size() == 0)
{
inventory.add(new Item(name, amount, price, location));
}
else
{
for(int i = 0; (!done)&&(i < inventory.size()); i++)
{
if(inventory.get(i).getName().equals(name))
{
System.out.println("Item name in use. Please use another name.");
done = true;
}
else
{
inventory.add(new Item(name, amount, price, location));
done = true;
}
}
}
}
/**
* Deletes an Item from the Inventory.
*/
public void deleteItem(String name)
{
...........
}
/**
* Search for an Item.
*/
public void searchItem(String name)
{
...........
}
}
http://docs.oracle.com/javase/tutorial/getStarted/ – 2014-09-05 02:27:15
I LOVE vim的 - 但我认为Java编码你可能有一个Java IDE的IntelliJ一样或者Eclipse这将好得多给你很多关于你的代码可能出错的提示。 – 2014-09-05 02:27:46
是的,但我必须用它来学习这门课。 – DaveMcFave 2014-09-05 02:59:53