原文:http://blog.csdn.net/pwair/article/details/654284 常量池(constant pool):指的是在编译期被确定,并被保存在已编译的.class文件中的一些数据。它包括了关于类、方法、接口等中的常量,也包括字符串常量。 Java确保一个字符串常量只
分类:
其他好文 时间:
2016-03-16 19:13:17
阅读次数:
206
C++下用宏来实现.分别是__FILE__,__func__,__LINE__分别代表,C++编译自动在每个文件中设定__FILE__类型是字符串常量 ,将__LINE__替换为当前行数,类型是数字常量,将在每个函数设定__FUNC__类型是字符串常量. JAVA下用StackTraceElemen
分类:
编程语言 时间:
2016-03-11 16:54:28
阅读次数:
154
函数不能返回指向栈内存的指针!因为返回的都是值拷贝! char *str = "abcd"这样就是字符串常量,这种能返回,而char str[] = "abcd"就不能在函数中返回了,因为这个是局部变量,函数结束后就内存释放了 如果非要进行返回局部变量,就只能用static来限制局部变量了,这样函数
分类:
编程语言 时间:
2016-03-08 23:55:28
阅读次数:
259
java 中的String类型 (1)String类型的数据可以表示所有的数据类型。 (2)String中的字符串常量与一般的字符串: String str0 = "hello";//字符串常量“hello”被预先放到了数据段的字符串常量池中 String str1 = "hello";//直接从常
分类:
编程语言 时间:
2016-03-07 19:12:24
阅读次数:
165
常用类 String input=JOptionPane.showInPutDialog();//输入框 JOptionPane.showMessageDialog(,)//消息框 String类 String str0 = "hello";//字符串常量“hello”被预先放到了数据段的字符串常量
分类:
其他好文 时间:
2016-03-07 13:52:27
阅读次数:
162
如上为库函数strcat的仿写功能为连接两个字符串
char*strat(char*dst,constchar*src)
{
char*cp=(char*)calloc(12,sizeof(char));//申请一块够大的内存足以存放两个字符串
char*cq=cp;
strcpy(cp,dst);//把目的字符串拷到申请的内存中
while(*cq)
cq++;
while(*src)//完..
分类:
其他好文 时间:
2016-03-04 22:51:05
阅读次数:
286
intern方法 public class Main { public static void main(String[] args) { String str1 = new String("asd"); String str2 = str1.intern();/* 字符串常量池中有,就返回字符串,
分类:
编程语言 时间:
2016-03-02 23:52:35
阅读次数:
250
public class 字符串 { static int i=0; public static void main (String ages[]){ final String a="字符串常量"; String b="字符串常量"; //String s=new String("字符串常量");/
分类:
其他好文 时间:
2016-03-01 08:36:20
阅读次数:
123
public static void main(String[] args) { //String String str = "字符串常量字符串常量"; String str1 = new String("字符串常量"); //构造方法 String str2 = new String("字符串常量
分类:
其他好文 时间:
2016-03-01 00:36:57
阅读次数:
241
@Test public void stringTest(){ /* * str1和str2地址指向字符串常量池 * 解析: str1 在字符串常量池中创建出java 地址例如为:0x456 * str2建立时会去常量池中找是否有java 有的话赋值 str2地址为0x456 * str3和str4
分类:
其他好文 时间:
2016-02-26 20:29:03
阅读次数:
126