字面量的表示:
整数:
小数:
科学计数法:
String可以使用单引号或者双引号作为字符串的定界符号:
Boolean:
练习如下
三个pojo类
package cn.com.day04;
public class Cars {
private String brand;
private Integer price;
// 轮胎的周长
private double circle;
public void setCircle(double circle) {
this.circle = circle;
}
public void setBrand(String brand) {
this.brand = brand;
}
public void setPrice(Integer price) {
this.price = price;
}
public Integer getPrice() {
return price;
}
public Cars() {
// TODO Auto-generated constructor stub
}
@Override
public String toString() {
return "Cars [brand=" + brand + ", price=" + price + ", circle="
+ circle + "]";
}
}
package cn.com.day04;
public class Address {
private String add;
private String id;
public void setAdd(String add) {
this.add = add;
}
public void setId(String id) {
this.id = id;
}
public String getAdd() {
return add;
}
@Override
public String toString() {
return "Address [add=" + add + ", id=" + id + "]";
}
public Address() {
// TODO Auto-generated constructor stub
System.out.println("address constructor....");
}
}
package cn.com.day04;
public class Person {
private String name;
private String as;
private Cars car;
private String info;
public void setName(String name) {
this.name = name;
}
public void setAs(String add) {
this.as = add;
}
public void setCar(Cars car) {
this.car = car;
}
public void setInfo(String info) {
this.info = info;
}
@Override
public String toString() {
return "Person [name=" + name + ", as=" + as + ", car=" + car + ", info="
+ info + "]";
}
public Person() {
// TODO Auto-generated constructor stub
System.out.println("deal......");
}
}
测试类
package cn.com.day04;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestMain {
public static void main(String[] args) {
//1.创建ioc容器
System.out.println("heheh");
//1.创建ioc容器
ApplicationContext cox=new ClassPathXmlApplicationContext("bean-spel.xml");
//2.获取bean
// Cars c1=(Cars) cox.getBean("car");
// System.out.println(c1);
// Address a1=(Address)cox.getBean("address");
// System.out.println(a1);
System.out.println("hahah");
Person pp=(Person) cox.getBean("person1");
System.out.println(pp);
}
}
bean配置文件如下
结果如下