import关键字

import介绍:

在这里插入图片描述

import关键字的使用:(导入类和接口)

import导入

  • 在源文件中显示的使用import结构导入指定包下的类、接口
  • 声明在包的声明和类的声明之间
  • 如果需要导入多个结构,则并行写出即可。
  • 使用xxx.* 的方式可以导入xxx包下所有的类或接口
  • 如果使用的类或接口是本包中定义的,则可以省略import结构
  • 如果使用的类或接口是java.lang包下定义的,则可以省略import结构
  • 在源文件中,使用了不同包下同名的类,其中一个类必须以全类名的方式显示出来
  • com.myobjectoriented011.nonworking.Customer cus01=new com.myobjectoriented011.nonworking.Customer(“abraham”,“goldman”);
  • 使用xxx.* 表明可以调用xxx包下的所有结构,但是如果使用的是xxx子包下的结构,仍然需要重新import调用
  • import com.包.类
  • import static:导入指定类或接口中的静态结构:属性或方法// import static java.lang.System.*; // out.println(“hello”);

直接看代码:

package com.myarr.nonworking;

import com.myobjectoriented01.nonworking.Customer;
import com.myobjectoriented011.nonworking.BankCustomerText;
import static java.lang.System.*;
import static java.lang.Math.*;

public class ImportText {
public static void main(String[] args) {
	
	BankCustomerText bank=new BankCustomerText();
	
	Customer cus=new Customer("a","b");
	
	com.myobjectoriented011.nonworking.Customer cus01=new com.myobjectoriented011.nonworking.Customer("abraham","goldman");
	
	
	
                  out.println("hello");
                  
                  
                 int num=addExact(2, 3);
                 out.println(num);
}
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值