当类中用到一些固定值时,希望将其定义为const成员变量,防止被修改。但因为const成员变量因为初始化之后就不能修改,因此只能在构造函数的初始化列表中初始化如果是数组,则没有办法在初始化列表中初始化,必须定义为static,放在类外定义例子://const_array.h#include
usin...
分类:
其他好文 时间:
2014-05-12 12:16:52
阅读次数:
228
举例1:使用BeanUtils工具封装用户提交的数据。 1 public static
void main(String[] args)throws Exception { 2 3 // 模拟用户的输入的数据如下 4 5 String name =
"XML基础"; ...
分类:
其他好文 时间:
2014-05-12 12:05:34
阅读次数:
211
using System;using
System.Collections.Generic;using System.Linq;using System.Text;namespace
ConsoleApplication1{ class Program { static void Main(stri...
分类:
其他好文 时间:
2014-05-12 11:46:04
阅读次数:
215
简单工厂模式(Simple Factory
Pattern)属于类的创新型模式,又叫静态工厂方法模式(Static FactoryMethod
Pattern),是通过专门定义一个类来负责创建其他类的实例,被创建的实例通常都具有共同的父类。
分类:
其他好文 时间:
2014-05-12 11:20:18
阅读次数:
254
?.class文件内的代码所在的文件的路径默认 1 举例1:读取项目根目录下的数据。 2
private static void readRoot() throws FileNotFoundException, IOException { 3
BufferedReader br = new ...
分类:
其他好文 时间:
2014-05-12 11:13:12
阅读次数:
283
C#控制台测试 class Program { static void Main(string[]
args) { decimal rmb = Convert.ToDecimal(Console.ReadLine()); ...
分类:
其他好文 时间:
2014-05-12 10:42:25
阅读次数:
377
1、选择表达式中的类型转换public class Test { public void static
main(String args[]){ int i = 5; System.out.println("Vlaue Is " + ((...
分类:
编程语言 时间:
2014-05-12 09:39:52
阅读次数:
294
//把秒转换成分钟 /// /// 把秒转换成分钟 /// /// public static int
SecondToMinute(int Second) { // / 换成 * 号...
分类:
其他好文 时间:
2014-05-12 09:33:41
阅读次数:
198
包名命名规范:1、包名全部小写2、包名一般情况下是域名的倒过来写+个性命名,如:tinyphp.com,就写成com.tinyphp+.xxx打包方法package
+ 包名package test; class Test{ public static void main(String ...
分类:
编程语言 时间:
2014-05-10 18:31:43
阅读次数:
308
一、枚举传统的方式:?在某些情况下,一个类的对象是有限而且固定的。例如季节类,只能有 4
个对象?手动实现枚举类:—private 修饰构造器。—属性使用 private final 修饰。—把该类的所有实例都使用 public static
final 来修饰。练习代码: 1 public cla...
分类:
编程语言 时间:
2014-05-10 06:45:30
阅读次数:
498