导航:首页 > 编程语言 > noargumentjava

noargumentjava

发布时间:2025-07-13 05:36:15

⑴ 常见的java异常有哪些都是什么意思

1、ArithmeticException - 算术运算中,被0除或模除。

2、 - 数组越界访问。

3、ArrayStoreException - 数据存储异常,写数组操作时,对象或数据类型不兼容。

4、ClassCastException - 类型转换异常。

5、IllegalArgumentException - 方法的参数无效。

6、IllegalThreadStateException - 试图非法改变线程状态,比方说试图启动一已经运行的线程。

7、NullPointerException - 试图访问一空对象的变量、方法或空数组的元素

8、NumberFormatException - 数据格式异常,试图把一字符串非法转换成数值(或相反)。

9、SecurityException - 如果Applet试图执行一被WWW浏览器安全设置所禁止的操作。

10、 - 如改变了某一类定义,却没有重新编译其他引用了这个类的对象。如某一成员变量的声明被从静态改变为非静态,但其他引用了这个变量的类却没有重新编译,或者相反。

11、OutOfMemoryException - 内存不足,通常发生于创建对象之时。

12、NoClassDefFoundException - JAVA运行时系统找不到所引用的类。

13、IncompatibleTypeException - 试图实例化一个接口,Java运行时系统将抛出这个异常。

14、UnsatisfiedLinkException - 如果所需调用的方法是C函数,但Java运行时系统却无法连接这个函数。

15、InternalException - 系统内部故障所导致的异常情况,可能是因为Java运行时系统本身的原因。如果发现一可重现的InternalException,可以直接给Sun公司发电邮[email protected]

⑵ java小程序源代码,简单点的,100多行,谁有啊

// My car shop.java

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.*;

public class carshop extends JFrame
{
// JPanel to hold all pictures
private JPanel windowJPanel;
private String[] cars = { "","阿斯顿马丁", "美洲虎", "凯迪拉克",
"罗孚", "劳斯莱斯","别克"};
private int[] jiage = { 0,150000, 260000, 230000,
140000, 290000, 150000};
// JLabels for first snack shown
private JLabel oneJLabel;
private JLabel oneIconJLabel;

// JLabels for second snack shown
private JLabel twoJLabel;
private JLabel twoIconJLabel;

// JLabels for third snack shown
private JLabel threeJLabel;
private JLabel threeIconJLabel;

// JLabels for fourth snack shown
private JLabel fourJLabel;
private JLabel fourIconJLabel;

// JLabels for fifth snack shown
private JLabel fiveJLabel;
private JLabel fiveIconJLabel;

// JLabels for sixth snack shown
private JLabel sixJLabel;
private JLabel sixIconJLabel;

// JTextField for displaying snack price
private JTextArea displayJTextArea;

// JLabel and JTextField for user input
private JLabel inputJLabel;
private JComboBox selectCountryJComboBox;

private JLabel inputJLabel2;
private JTextField inputJTextField2;

// JButton to enter user input
private JButton enterJButton;

//JButton to clear the components
private JButton clearJButton;

// no-argument constructor
public carshop()
{
createUserInterface();
}

// create and position GUI components; register event handlers
private void createUserInterface()
{
// get content pane for attaching GUI components
Container contentPane = getContentPane();

// enable explicit positioning of GUI components
contentPane.setLayout( null );

// set up windowJPanel
windowJPanel = new JPanel();
windowJPanel.setBounds( 10, 20, 340, 200 );
windowJPanel.setBorder( new LineBorder( Color.BLACK ) );
windowJPanel.setLayout( null );
contentPane.add( windowJPanel );

// set up oneIconJLabel
oneIconJLabel = new JLabel();
oneIconJLabel.setBounds( 10, 20, 100, 65 );
oneIconJLabel.setIcon( new ImageIcon( "images/阿斯顿马丁.jpg" ) );
windowJPanel.add( oneIconJLabel );

// set up oneJLabel
oneJLabel = new JLabel();
oneJLabel.setBounds( 10, 60, 100, 70 );
oneJLabel.setText( "阿斯顿马丁" );
oneJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( oneJLabel );

// set up twoIconJLabel
twoIconJLabel = new JLabel();
twoIconJLabel.setBounds( 120, 20, 100, 65 );
twoIconJLabel.setIcon( new ImageIcon( "images/美洲虎.jpg" ) );
windowJPanel.add( twoIconJLabel );

// set up twoJLabel
twoJLabel = new JLabel();
twoJLabel.setBounds( 110, 60, 100, 70 );
twoJLabel.setText( "美洲虎" );
twoJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( twoJLabel );

// set up threeIconJLabel
threeIconJLabel = new JLabel();
threeIconJLabel.setBounds( 230, 20, 100, 65 );
threeIconJLabel.setIcon( new ImageIcon(
"images/凯迪拉克.jpg" ) );
windowJPanel.add( threeIconJLabel );

// set up threeJLabel
threeJLabel = new JLabel();
threeJLabel.setBounds( 230, 60, 100, 70);
threeJLabel.setText( "凯迪拉克" );
threeJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( threeJLabel );

// set up fourIconJLabel
fourIconJLabel = new JLabel();
fourIconJLabel.setBounds( 10, 100, 100, 65 );
fourIconJLabel.setIcon( new ImageIcon( "images/罗孚.jpg" ) );
windowJPanel.add( fourIconJLabel );

// set up fourJLabel
fourJLabel = new JLabel();
fourJLabel.setBounds( 10, 150, 50, 70 );
fourJLabel.setText( "罗孚" );
fourJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fourJLabel );

// set up fiveIconJLabel
fiveIconJLabel = new JLabel();
fiveIconJLabel.setBounds( 120, 100, 100, 65 );
fiveIconJLabel.setIcon( new ImageIcon(
"images/劳斯莱斯.jpg" ) );
windowJPanel.add( fiveIconJLabel );

// set up fiveJLabel
fiveJLabel = new JLabel();
fiveJLabel.setBounds( 110, 150, 100, 70 );
fiveJLabel.setText( "劳斯莱斯" );
fiveJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fiveJLabel );

// set up sixIconJLabel
sixIconJLabel = new JLabel();
sixIconJLabel.setBounds( 230, 100, 100, 65 );
sixIconJLabel.setIcon( new ImageIcon( "images/别克.jpg" ) );
windowJPanel.add( sixIconJLabel );

// set up sixJLabel
sixJLabel = new JLabel();
sixJLabel.setBounds( 230, 150, 100, 70 );
sixJLabel.setText( "别克" );
sixJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( sixJLabel );

// set up enterJButton
enterJButton = new JButton();
enterJButton.setBounds( 390, 160, 135, 30 );
enterJButton.setText( "Enter" );
contentPane.add( enterJButton );
enterJButton.addActionListener(

new ActionListener() // anonymous inner class
{
// event handler called when enterJButton is clicked
public void actionPerformed( ActionEvent event )
{
enterJButtonActionPerformed( event );
}

} // end anonymous inner class

); // end call to addActionListener

// set up clearJButton
clearJButton = new JButton();
clearJButton.setBounds( 390, 200, 135, 30 );
clearJButton.setText( "Clear" );

contentPane.add( clearJButton );

// set up inputJLabel

inputJLabel = new JLabel();
inputJLabel.setBounds( 390, 25, 135, 25 );
inputJLabel.setText( "Please make selection:" );
contentPane.add( inputJLabel );

selectCountryJComboBox = new JComboBox( cars );
selectCountryJComboBox.setBounds( 390, 50, 135, 21 );
selectCountryJComboBox.setMaximumRowCount( 3 );
contentPane.add( selectCountryJComboBox );
// set up inputJTextField

inputJLabel2 = new JLabel();
inputJLabel2.setBounds( 390, 80, 150, 20 );
inputJLabel2.setText( "Input the Numble:" );
contentPane.add( inputJLabel2 );

// set up inputJTextField
inputJTextField2 = new JTextField();
inputJTextField2.setBounds( 390, 100, 135, 25 );
inputJTextField2.setHorizontalAlignment( JTextField.RIGHT );
contentPane.add( inputJTextField2 );

clearJButton.addActionListener(

new ActionListener() // anonymous inner class
{
// event handler called when clearJButton is clicked
public void actionPerformed( ActionEvent event )
{
clearJButtonActionPerformed( event );
}

} // end anonymous inner class
);

// set up displayJTextField
displayJTextArea = new JTextArea();
displayJTextArea.setBounds( 10, 237,515, 70 );
displayJTextArea.setEditable( false );
contentPane.add( displayJTextArea );
// set properties of application's window
setTitle( "My car Shop" ); // set title bar string
setSize( 550, 360 ); // set window size
setVisible( true ); // display window

} // end method createUserInterface

private void clearJButtonActionPerformed( ActionEvent event )
{
// clear the JTextFields
inputJTextField2.setText( "" );
displayJTextArea.setText("");

} // end method clearJButtonActionPerformed

private void enterJButtonActionPerformed( ActionEvent event )
{
double z;
double c;
int x;
int y;
x=selectCountryJComboBox.getSelectedIndex();
y=Integer.parseInt(inputJTextField2.getText());
double discountRate;
int amount = Integer.parseInt( inputJTextField2.getText());
switch (amount/5)
{
case 0:
discountRate = 0;
break;

case 1:
discountRate = 1;
break;

case 2:
discountRate = 2;
break;
case 3:
discountRate = 3;
break;

default:
discountRate = 4;

} // end switch statement
c=1-discountRate/100;
z=jiage[x]*y*c;
displayJTextArea.append("你选择的是:"+cars[x]+";"+
"它的单价是:"+jiage[x]+";" +"你购买该产品的数量是:"+y+"," +"\n"+"该数量的折扣是:"
+discountRate + " %"+";"+"本次消费的总价格是:"+z+"元"+"!"+"\n");

}
public static void main( String args[] )
{
carshop application = new carshop();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

} // end method main

} // end class carshop

⑶ 常见JAVA运行时异常有哪些

1,java.lang.NullPointerException

这个异常的解释是 "程序遇上了空指针 ",简单地说就是调用了未经初始化的对象或者是不存在的对象,这个错误经常出现在创建图片,调用数组这些操作中,比如图片未经初始化,或者图片创建时的路径错误等等。

2,java.lang.ClassNotFoundException

异常的解释是"指定的类不存在",这里主要考虑一下类的名称和路径是否正确即可

3,java.lang.

这个异常的解释是"数组下标越界",现在程序中大多都有对数组的操作,因此在调用数组的时候一定要认真检查,看自己调用的下标是不是超出了数组的范围,一般来说,显示(即直接用常数当下标)调用不太容易出这样的错,但隐式(即用变量表示下标)调用就经常出错了.

4,java.lang.NoSuchMethodError

方法不存在错误。当应用试图调用某类的某个方法,而该类的定义中没有该方法的定义时抛出该错误。

5,java.lang.IndexOutOfBoundsException

索引越界异常。当访问某个序列的索引值小于0或大于等于序列大小时,抛出该异常。

6,java.lang.NumberFormatException

数字格式异常。当试图将一个String转换为指定的数字类型,而该字符串确不满足数字类型要求的格式时,抛出该异常。

7,java.sql.SQLException

Sql语句执行异常

8,java.io.IOException

输入输出异常

9,java.lang.IllegalArgumentException

方法参数错误

10java.lang.IllegalAccessException

无访问权限异常

(3)noargumentjava扩展阅读:

Java技术应用领域:

1、Android应用

许多的 Android应用都是Java程序员开发者开发。虽然 Android运用了不同的JVM以及不同的封装方式,但是代码还是用Java语言所编写。相当一部分的手机中都支持JAVA游戏,这就使很多非编程人员都认识了JAVA。

2、在金融业应用的服务器程序

Java在金融服务业的应用非常广泛,很多第三方交易系统、银行、金融机构都选择用Java开发,因为相对而言,Java较安全 。大型跨国投资银行用Java来编写前台和后台的电子交易系统,结算和确认系统,数据处理项目以及其他项目。

3、网站

Java 在电子商务领域以及网站开发领域占据了一定的席位。开发人员可以运用许多不同的框架来创建web项目,SpringMVC,Struts2.0以及frameworks。即使是简单的 servlet,jsp和以struts为基础的网站在政府项目中也经常被用到。例如医疗救护、保险、教育、国防以及其他的不同部门网站都是以Java为基础来开发的。

4、嵌入式领域

Java在嵌入式领域发展空间很大。在这个平台上,只需130KB就能够使用Java技术(在智能卡或者传感器上)。

5、大数据技术

Hadoop以及其他大数据处理技术很多都是用Java,例如Apache的基于Java的HBase和Accumulo以及 ElasticSearchas。

6、高频交易的空间

Java平台提高了这个平台的特性和即使编译,他同时也能够像 C++ 一样传递数据。正是由于这个原因,Java成为的程序员编写交易平台的语言,因为虽然性能不比C++,但开发人员可以避开安全性,可移植性和可维护性等问题。

7、科学应用

Java在科学应用中是很好选择,包括自然语言处理。最主要的原因是因为Java比C++或者其他语言相对其安全性、便携性、可维护性以及其他高级语言的并发性更好。

⑷ 在Java中使用键盘输入数据的几种方法

在Java中,有多种方法可以实现键盘输入数据,以下是一些常用的技巧:
1. 使用控制台输入数据
1.1. 使用主方法的形式参数
在Java中,可以通过`main(String[] args)`方法接受命令行参数。
```java
package InputTest;
public class DataKeyboardInput1 {
/**
* 使用主方法的形式参数来输入数据
* DataKeyboardInput1.java
* @param args
*/
public static void main(String[] args) {
// 输出传递给程序的第一个参数
if (args.length > 0) {
System.out.println(args[0]);
} else {
System.out.println("No argument provided.");
}
}
}
```
在命令行中运行程序并传递参数:`java DataKeyboardInput1 HelloWorld`,输出将是 `HelloWorld`。
1.2. 利用字节输入流
使用`System.in`作为`InputStream`的实例,调用`read()`方法读取数据。
```java
package InputTest;
import java.io.*;
public class DataKeyboardInput2 {
/**
* 利用字节输入流来输入数据
* DataKeyboardInput2.java
* @param args
*/
public static void main(String[] args) {
// 定义字节数组以读取输入
byte[] buf = new byte[10];
String str;
int num = 0;
try {
// 读取到字节数组中
int count = System.in.read(buf);
// 转换为字符串
str = new String(buf, 0, count);
// 转换为整型数据
num = Integer.parseInt(str.trim());
} catch (Exception e) {
System.out.print(e);
}
System.out.println(num);
}
}
```
1.3. 利用字符输入流
`BufferedReader`类提供了缓冲字符输入流的功能,常用`readLine()`方法读取一行文本。
```java
package InputTest;
import java.io.*;
public class DataKeyboardInput3 {
/**
* 利用字符输入流来进行输入处理
* @param args
*/
public static void main(String[] args) throws IOException {
// 使用BufferedReader读取输入
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
int num = 0;
try {
str = br.readLine();
num = Integer.parseInt(str);
} catch (IOException e) {
System.out.println(e.toString());
}
System.out.println(num);
}
}
```
1.4. 利用文本扫描类
`Scanner`类可以从字符串中解析出不同类型的数据,使用正则表达式进行分隔。
```java
package InputTest;
import java.util.Scanner;
public class DataKeyboardInput4 {
/**
* 利用文本扫描类来进行输入处理
* @param args
*/
public static void main(String[] args) {
// 使用Scanner类读取输入
Scanner input = new Scanner(System.in);
int num = input.nextInt();
System.out.println(num);
}
}
```
2. 对话框输入数据
使用`JOptionPane`创建输入对话框,实现键盘输入。
```java
package InputTest;
import javax.swing.JOptionPane;
public class DataInputDialog {
/**
* 对话框输入数据
* @param args
*/
public static void main(String[] args) {
// 使用JOptionPane显示输入对话框
String str;
str = JOptionPane.showInputDialog("input data:");
if (str != null) {
int num = Integer.parseInt(str);
System.out.println(num);
}
}
}
```
以上示例代码展示了在Java中获取用户输入的几种不同方式。

阅读全文

与noargumentjava相关的资料

热点内容
麦当劳app如何指定门店配送 浏览:347
音乐树app怎么操作 浏览:642
三棱柱晶胞的算法 浏览:387
飞贷app如何注销账号 浏览:228
服务器如何支持大量数据的读写 浏览:601
汽车压缩机磁吸不转 浏览:549
python做网站登录 浏览:242
查看javaapi 浏览:954
编程猫电子表格 浏览:525
扣扣如何解除绑定的app 浏览:782
乐橙监控app如何用 浏览:198
编程最重要的是什么 浏览:974
excel函数大全pdf 浏览:527
便宜云服务器服务 浏览:113
三星pdf软件 浏览:292
子菜单里建立文件夹 浏览:779
用命令方块驱除生物 浏览:725
老男孩python怎么样 浏览:88
为什么python中etree报错 浏览:960
普米康APP怎么下载 浏览:879