如果总统改变了,我将不得不在下面改变presidentName三次的价值application-context.xml:
<beans:property name="presidentName" value="Barack Obama" />
Run Code Online (Sandbox Code Playgroud)
有没有办法设置变量一次application-context.xml来表示字符串Barack Obama.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<beans:bean id="testBeanA" class="com.TestBean">
<beans:property name="presidentName" value="Barack Obama" />
</beans:bean>
<beans:bean id="testBeanB" class="com.TestBean">
<beans:property name="presidentName" value="Barack Obama" />
</beans:bean>
<beans:bean id="testBeanC" class="com.TestBean">
<beans:property name="presidentName" value="Barack Obama" />
</beans:bean>
</beans:beans>
Run Code Online (Sandbox Code Playgroud) 我在我的应用中设置了这个日历:
Calendar cal = Calendar.getInstance();
cal.set(2010, 1, 10);
Run Code Online (Sandbox Code Playgroud)
我正在用这个SimpleDateFormat来表达月份:
SimpleDateFormat formatMonth = new SimpleDateFormat("MM");
Run Code Online (Sandbox Code Playgroud)
在一个课程中,它出来了.February 10th, 2010
在另一个它出来了.March 10th, 2010
哪个是对的?
要获得newString值" 99 bottles":
int x = 99;
String fruit = " bottles";
Run Code Online (Sandbox Code Playgroud)
要形成一个新的String,我这样做:
String newString = "" + x + fruit;
Run Code Online (Sandbox Code Playgroud)
因为这是不允许的:
String newString = x + fruit;
Run Code Online (Sandbox Code Playgroud)
但是这里使用双引号有点似乎不对.
有没有更好的方法来做到这一点(不使用"" + x)?