最近在开发中需要随机生成指定位数的随机数,想起来random类有一个误区,再次写出来让大家在开发中避免犯类似的错误。在java中对于Random类想必大家都知道是用来产生随机数的,但是稍有不慎就可能出现错误。例如:publicstaticvoidmain(String[]args){
Randomrandom=newRandom(..
分类:
编程语言 时间:
2015-03-03 11:54:29
阅读次数:
150
//中文转换成unicode码值
String str = "抢购人数太多,请稍后重试!" ;
char[]arChar=str.toCharArray();
int iValue=0;
String uStr="" ;
for(int i=0;i length;i++){
iValue=( int)str.charAt(i);
...
分类:
编程语言 时间:
2015-03-03 11:38:07
阅读次数:
203
将多列合并成一列ARRAY_TO_STRING(ARRAY[column1, column2, column3], ' ')" as new_column将column1, column2, column3合并,通过空格相连,取别名new_column
分类:
数据库 时间:
2015-03-03 11:36:07
阅读次数:
151
当我们在初学使用C#时,常常会不知道该用StringBuilder合适还是用String高效,下面是我在学习当中对StringBuilder和String的区别总结,分享给大家。 String类有不可改变性。每次执行字符操作时,都会创建一个新的String对象。 StringBuilder 类解决了...
分类:
其他好文 时间:
2015-03-03 11:31:24
阅读次数:
145
无参方法 功能:将方法的定义转换为属性字段的定义; 作用范围:方法中没有参数,并且方法仅能通过读取所包含的对象属性去访问可变状态,而不改变可变状态,就可使用无参方法; 例子: abstract class Element{ def texts:String } class Sub1Element(t...
分类:
其他好文 时间:
2015-03-03 11:24:00
阅读次数:
457
public class Test { public static void main(String[] args) { System.out.println(recursive(30)); } public static int recursive(...
分类:
其他好文 时间:
2015-03-03 11:17:43
阅读次数:
603
public static void WriteTextLog(string action, string strMessage, DateTime time) { string path = AppDomain.CurrentDomain.BaseDirectory + @"...
分类:
其他好文 时间:
2015-03-03 11:14:45
阅读次数:
156
NumberFormat 是所有数值格式的抽象基类。 该类提供了格式化和分析数值的接口,NumberFormat 也提供了确定 哪个语言环境具有数值格式以及它们名字的方法public class Test {public static void main(String[] args) { Doubl...
分类:
编程语言 时间:
2015-03-03 11:11:02
阅读次数:
192
要想使用标准C++中string类,必须要包含#include // 注意是,不是,带.h的是C语言中的头文件using std::string;using std::wstring;或using namespace std;下面你就可以使用string/wstring了,它们两分别对应着char和...
分类:
其他好文 时间:
2015-03-03 11:09:51
阅读次数:
167
大家都知道,java中JDBC中,有个预处理功能,这个功能一大优势就是能提高执行速度尤其是多次操作数据库的情况,再一个优势就是预防SQL注入,严格的说,应该是预防绝大多数的SQL注入。
用法就是如下边所示:
String sql="update cz_zj_directpayment dp"+
"set dp.projectid = ? where dp.payid= ?";
...
分类:
数据库 时间:
2015-03-03 10:01:12
阅读次数:
314