Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,搜索引擎的蜘蛛再怎么爬,能找到的无非是文字和连接

2,关键字覆盖范围并不是越宽越好,因为一旦搜索引擎发现关键字与网站内容不符,则认为是在舞弊,这样网站就极有可能被屏蔽,尽可能选择与网页目标市场相尽的关键词。

3,title里一般是网站的核心关键词,即目标关键词,也是搜索引擎比较注重的部分,不要堆积关键字。

description是比较重要的,一般他会和title一起出现在搜索结果里,所以description里不仅要包含你的目标关键词,还要是一段简单的话,向目标客户说明你网站的主题,你网站是做什么的,有什么优势。

注意文章的正文前100字,因为搜索引擎的关注顺序为:title?-description?-正文前100字

Title : 内容关键字(文章标题)热门关键字

<META NAME =”keywords” CONTENT=” “>

Keywords : 内容关键字,热门关键字,(多个)

<META NAME=”description” CONTENT=”关键字 页面主要内容”>

注:先在页面内容上尽可能多的加入热门关键字,之后再做title,keywords,description. 这三个要加入的内容主要来自内容所引用的热门关键字。一般:title:一句话或两个,keywords:三到五个 description:不多于80个字符。这三个内容要统一。开头要高度近似。选择关键字时要考虑的是用户会不会用此词来进行搜索,若不会,加入意义也不大


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

WindySky 个人图书倌 ? ? ? ? ? ? ? ? ? ? ? ?? http://www.360doc.com/forumfocus.aspx??????

?Java基础例子 ?????????? ? ? ? ? ? ? ? ? ? ? ? ?? ? http://www.exampledepot.com/egs/

?据类找JAR包?????????? ? ? ? ? ? ? ? ? ? ? ? ?? ? http://www.findjar.com/

?java在线API??????????? ? ? ? ? ? ? ? ? ? ? ? ? ? ? http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/index.html

?Hibernate3.2 API?????????? ? ? ? ? ? ? ? ?? ? ? http://www.hibernate.org/hib_docs/v3/api/

?Spring Framework API 2.5 ? ? ? ? ? ? ???? http://static.springframework.org/spring/docs/2.5.x/api/index.html

?Struts 1.3.8 API?????????????????????????? ? ?? http://struts.apache.org/1.3.8/apidocs/index.html

?Struts 2 Core 2.0.11.1 API ? ? ? ? ?? ?? ? http://struts.apache.org/2.0.11.1/struts2-core/apidocs/index.html

?Struts 2 标签API????????????????????????????? http://struts.apache.org/2.0.14/docs/tag-reference.html

?JSTL 标签 API? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html

JSTL?? 实现标签的类库 ? ? ? ? ? ? ? ? ? ?? http://java.sun.com/products/jsp/jstl/1.1/docs/api/index.html

Web Service API ???????????????????????????? http://java.sun.com/webservices/reference/apis-docs/index.jsp

JavaScript???? API???????????????????????????? http://krook.org/jsdom/????

???????????????????????????????????????????????????? http://www.gotapi.com/html

CSS,HTML在线学习??????????????????????? http://www.w3schools.com/

?据类名查看其方法???? ? ? ? ? ? ? ? ? ? ? ? http://www.docjar.com/

?看书????????????????????? ? ? ? ? ? ? ? ? ? ? ? ? http://book.csdn.net/
?
?维基百科???????????????? http://zh.wikipedia.org/w/index.php?title=Wikipedia:%E9%A6%96%E9%A1%B5&variant=zh-cn

?ajax?????????????????????? ? ? ? ? ? ? ? ? ? ? ? ? http://www.okajax.com/

?jquery ?????????????????????????????????????????? http://bbs.jquery.org.cn/index.php? goodasong 8a
?????????????????????????????????????????????????????
?jquery api ?????????????????????????????????????????????????? http://docs.jquery.com/

jquery 例子????????????????????????????????????? http://visualjquery.com/

正则表达式???????????????????????????????????? http://www.regexplib.com?? 在线测试:http://regexpal.com/

源程序????????????????????? http://sourceforge.net/index.php http://www.codeplex.com/???? 国内.net源码 http://www.51aspx.com/
???
服务器配置应用查询 ??http://tomcat.apache.org/

各种连接字符串:????? http://www.connectionstrings.com/

google api???????????????? http://code.google.com/intl/zh-CN/

JS?????????????????????????? http://www.ijavascript.cn/

博客园?????????????????? http://dotnet.cnblogs.com/
c#开发工具?? ??? ??? ??http://msdn.microsoft.com/zh-cn/vcsharp/aa336818.aspx
.NET开源网站 ? ? ? ?? http://www.openforge.cn/opendotnet/


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,和纯数字实现订单号,因为要保持唯一性,故一般按时间来生成果如:09 04 23 08 26 12 + 随机数字 12 56
优势在于快速,简单, 不利处在于生成的单号长度过长,不便于记录,宜出错。

2,数字加字母方式: 数字0~9,字母a~Z, 共62个字符,对于1种方式生成的单号,可以两位对应一个字符来实现。
实现方式:
? (1)定义一个数组,s[62] :s[0] =”A”, …s[25]=”Z”, s[26]=”0″…s[35]=”9″,s[36]=”a”,…s[61]=”z”
? (2)对应 09 04 23 08 26 12 12 56
????????????????? J?? E? X?? I??? 0?? M? M u
????????? 这样16位长度的订单号就转为8位就可完成表示。
????????? 09 04 23 08 26? 年,月,日,时,分,秒因最大都小于61,故以上可完全表示(ps:年的话,要考虑一个系统?? 很少可能从09年用到61年)
???????? 对于加的四位随机数, 按两位对应一个字符的方式,它的范围从00-99,可能就会随机出大于61的数字,
这样的话可以用? | a – 61? | 因0 < a < 99, 故 | a – 61 | <= 61 ( ps:有可能随机数字相同,不过在同天同时同分同秒随机出相同数字字符的概率非常之小,可忽略不计。 )


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

空格、Shift + 空格:上下翻一篇文章或者一页

  • ?
    • j/k ??? ?item down/up ??? ?上一个条目/下一个条目
    • v:查看原文
    • s ??? ?toggle star ??? ?标记所选择的条目星号(取消标记)
    • m?? ?mark as read/unread ?? ?标记为已读或未读
    • shift+a ??? ?mark all as read ??? ?标记所有条目为已读
    • ga ??? ?go to all items ??? ?显示所有条目
    • gs ?? ?go to starred items ?? ?显示已标记星号的条目
    • gt ?? ?go to tag ?? ?打开标签选择(这个很炫!)
    • gu ?? ?go to subscription ?? ?打开已订阅的RSS(一样很炫!)
    • Shift + x:折叠、展开文件夹


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
类 Runtime
每个 Java 应用程序都有一个 Runtime 类实例,使应用程序能够与其运行的环境相连接。可以通过 getRuntime 方法获取当前运行时。 

应用程序不能创建自己的 Runtime 类实例。 

1, 打开文件:Runtime.getRuntime().exec("vs.net.exe");

2, 执行ping命令

import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 


public class JavaPing{ 

public static void main(String[] args) {    
try {  
Process p = Runtime.getRuntime().exec("ping 192.168.1.86"); 
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));  //获取执行结果
String line = "";  
while ((line = br.readLine()) != null) {  
System.out.println(line);  
}  
br.close();  
} catch (IOException e) {  
e.printStackTrace();  
}  
} 
}

注:类 Process ,进程类


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

两种import语句:

1, 单类型导入(single-type-import),例如import java.io.File;
按需类型导入(type-import-on-demand),例如 import java.io.*;
单类型导入比较好理解,仅仅导入一个public类或者接口。而对于按需类型导入,有人误解为导入一个包下的所有类,其实不然,看名字就知道,他只会按需导入,也就是说它并非导入整个包,而仅仅导入当前类需要使用的类。按需类型导入是绝对不会降低Java代码的执行效率的,但会影响到Java代码的编译速度。

大型工程中,一般的书写建议是:
必须采用单类型引入,而且即使是同一个package下的,也要import,因为大型工程编译时间长。

2, import??? java.awt.*;??
import??? java.awt.event.*;??
…??
二者不一样,
java.awt.*没有包括java.awt.event.*,
*只能代表当前文件夹中所有类,不包括它的下一级文件夹中的类。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

在写代码的时候为了避免手误,把“==”(判等)敲成“=”(赋值)引起错误,推荐采用 if(常量 == 变量) 的模式。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
一,, 读取文件
 File file=new File( filePath );
 SAXReader sar=new SAXReader();
 Document doc = sar.read(file);

二,操作数据

1.获取文档的根节点.
Element rootElm = document.getRootElement(); 

2.取得某节点的单个子节点.
Element memberElm=root.element("member");// "member"是节点名 

3.取得节点的文字
String text=memberElm.getText(); 也可以用:
String text=root.elementText("name"); 这个是取得根节点下的name字节点的文字.

4.取得某节点下名为"member"的所有字节点并进行遍历.
List nodes = rootElm.elements("member");
for (Iterator it = nodes.iterator(); it.hasNext();) {
Element elm = (Element) it.next();
// do something
} 

5.对某节点下的所有子节点进行遍历.
for(Iterator it=root.elementIterator();it.hasNext();){
Element element = (Element) it.next();
// do something
} 

6.在某节点下添加子节点.
Element ageElm = newMemberElm.addElement("age"); 

7.设置节点文字.
ageElm.setText("29"); 

8.删除某节点.
parentElm.remove(childElm);// childElm是待删除的节点,parentElm是其父节点 

9.添加一个CDATA节点.
Element contentElm = infoElm.addElement("content");
contentElm.addCDATA(diary.getContent());
contentElm.getText(); // 特别说明:获取节点的CDATA值与获取节点的值是一个方法
contentElm.clearContent(); //清除节点中的内容,CDATA亦可

三.属性相关.
1.取得某节点下的某属性
Element root=document.getRootElement(); 
Attribute attribute=root.attribute("size");// 属性名name

2.取得属性的文字
String text=attribute.getText();
也可以用:
String text2=root.element("name").attributeValue("firstname");
这个是取得根节点下name字节点的属性firstname的值.

3.遍历某节点的所有属性
Element root=document.getRootElement(); 
for(Iterator it=root.attributeIterator();it.hasNext();){
Attribute attribute = (Attribute) it.next();
String text=attribute.getText();
System.out.println(text);
}

4.设置某节点的属性和文字.
newMemberElm.addAttribute("name", "sitinspring");

5.设置属性的文字
Attribute attribute=root.attribute("name");
attribute.setText("sitinspring");

6.删除某属性
Attribute attribute=root.attribute("size");// 属性名name
root.remove(attribute);

四.将文档写入XML文件.
1.文档中全为英文,不设置编码,直接写入的形式.
XMLWriter writer = new XMLWriter(new FileWriter("output.xml"));
writer.write(document);
writer.close();

2.文档中含有中文,设置编码格式写入的形式.
     OutputFormat format = OutputFormat.createPrettyPrint();
     format.setEncoding("GBK");    // 指定XML编码        
     XMLWriter writer = new XMLWriter(new FileWriter("output.xml"),format);
    
     writer.write(document);
     writer.close();

五.字符串与XML的转换
1.将字符串转化为XML
String text = " sitinspring ";
Document document = DocumentHelper.parseText(text);

2.将文档或节点的XML转化为字符串.
     SAXReader reader = new SAXReader();
     Document   document = reader.read(new File("input.xml"));            
     Element root=document.getRootElement();                
     String docXmlText=document.asXML();
     String rootXmlText=root.asXML();
     Element memberElm=root.element("member");
     String memberXmlText=memberElm.asXML();


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
1 Test.class.getResource("");    当前类所在的地址
file:/E:/workspace/lj/WebRoot/WEB-INF/classes/com/lvjian/mail/

2 Test.class.getResource("/");  类的包所在的路径
file:/E:/workspace/lj/WebRoot/WEB-INF/classes/

//Class文件所在路径 
3 new File("/").getAbsolutePath(); //根路径,相对于磁盘
E:\

4 System.getProperty("user.dir");  //工程目录             E:\workspace\lj
                                  在Tomcat服务器上在类中输出System.getProperty("user.dir");显示的%Tomcat_Home%/bin

得到classes下的配置文件在类中用:
String filePath = XML.class.getResource("/").toString();
filePath = filePath.substring( 5 )+ "lvjian.xml";


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

JAR文件就是将一些class文件打包,生成.jar文件,此操作类似于用winrar进行打包工作
JAR的操作: 可用winrar打开,直接增加,删除其中的文件

典型的用法是:j2ee 5.0 的mail.jar, activation.jar不完整,要删除之后导入正克的jar文件,就是通过用
??? winrar删除此文件,导入正确的文件完成的。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

使用commons-email发邮件
commons-email是apache提供的一个开源的API,是对javamail的封装,因此在使用时要将mail.jar , activation.jar 加到 class path中,主要包括SimpleEmail,MultiPartEmail,HtmlEmail,EmailAttachment四个类。

注:当是j2se时因没有mail,activation包,故要加入这两个包,而对于j2ee.它本身自带这两个包,就不用再导入,可直接用。
要注意的一点是:j2ee5.0的mail.jar, activation.jar包中相关的类是不完整的,不能直接用,但若直接导入这两个包,又会造成
j2ee与导入的包冲突,解决方法是:找到j2ee.jar文件 ,用winrar打开,删除mail.jar, activation.jar,再导入 这两个包,就OK

SimpleEmail:发送简单的email,不能添加附件
MultiPartEmail:文本邮件,可以添加多个附件
HtmlEmail:HTML格式邮件,同时具有MultiPartEmail类所有“功能”
EmailAttchment:附件类,可以添加本地资源,也可以指定网络上资源,在发送时自动将网络上资源下载发送。

发送基本文本格式邮件:
==============
SimpleEmail email = new SimpleEmail();

//设置发送主机的服务器地址

email.setHostName(“smtp.gmail.com”);

//设置收件人邮箱

email.addTo(“cang521ying@yahoo.com.cn”,”cang521ying”);
//抄送:addCC 密送: addBcc CC:Carbon Copy BCC:Blind Carbon Copy Carbon( 碳,复本,复写本)

//发件人邮箱

email.setFrom(“goodasong@gmail.comm”,”goodasong”);

email.setDebug(true); //用来调试,打印出错误信息,正式运行时要注释掉
email.setSSL(true); //因用的是Gmail邮箱发送,故pop设置要符合Gmail的要求
email.setSmtpPort(465);

email.setAuthentication(“goodasong@gmail.com”, ““);

//设置邮件的主题

email.setSubject(“Hello, This is My First Email Application”);

//邮件正文消息
//最好进行转码,防止乱码,因要在网络中传输,而网络多用iso-8859-1发送,故要从gbk转成iso-8859-1
String content = “这是个测试!”;
content = new String(content.getBytes(“gbk”),”iso-8859-1″);
email.setMsg(content);

email.send();

各个邮箱的pop3的不同设置 ( 一般都要参考各个邮箱帮助中的outlook设置 )

1,在用某一品牌的邮箱发送邮件时首先要确保的是此邮箱的pop3开启
如Gmail的设置在:设置 — 转发和POP/IMAP – 针对所有邮件启用 POP(包括已经下载的邮件)
sina的设置在: 邮箱设置 — 账户 — 开启
163 需要VIP才可用outlook,意味着只有VIP账户才能进行发磅
注意记下各个smtp服务器名称,email.setHostName(“smtp.gmail.com”); sina 为 smtp.sina.com

2,在各个邮箱的帮助里看对outlook的设置,除了用户名,密码之外是否还要设置其它,像sina就不用,
而Gmail需要此服务器要求安全连接 (SSL) 启用
发送邮件服务器 (SMTP): 465 或 25

即:email.setSSL(true);
email.setSmtpPort(465);


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
 commons-email是apache提供的一个开源的API,是对javamail的封装,因此在使用时要将javamail.jar加到 class path中,主要包括SimpleEmail,MultiPartEmail,HtmlEmail,EmailAttachment四个类。
 
SimpleEmail:发送简单的email,不能添加附件
MultiPartEmail:文本邮件,可以添加多个附件
HtmlEmail:HTML格式邮件,同时具有MultiPartEmail类所有“功能”
EmailAttchment:附件类,可以添加本地资源,也可以指定网络上资源,在发送时自动将网络上资源下载发送。
 
发送基本文本格式邮件:
==============
SimpleEmail email = new SimpleEmail();
//smtp host 
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setMsg("This is a simple test of commons-email");
//发送
email.send();

发送文本格式,带附件邮件:
==================
//附件,可以定义多个附件对象
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("e:\\1.pdf");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
//
MultiPartEmail email = new MultiPartEmail();
//smtp host 
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setMsg("This is a simple test of commons-email");
//添加附件
email.attach(attachment);
//发送
email.send();
 
发送HTML格式带附件邮件:
=================
//附件,可以定义多个附件对象
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("e:\\1.pdf");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
//
HtmlEmail email = new HtmlEmail ();
//smtp host 
email.setHostName("mail.test.com");
//登陆邮件服务器的用户名和密码
email.setAuthentication("test","testpassword");
//接收人
email.addTo("jdoe@somewhere.org", "John Doe");
//发送人
email.setFrom("me@apache.org", "Me");
//标题
email.setSubject("Test message");
//邮件内容
email.setHtmlMsg("This is a simple test of commons-email");
//添加附件
email.attach(attachment);
//发送
email.send(); 


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?如:
?Iterator<PowerInfo> it = list.iterator();
??? ??? while( it.hasNext() ){
?????????? PowerInfo temp = it.next();
??? ??? ??? if ( it.next.getName().equals(“teset”) ){
??? ?? ??? ??? ?list.remove(? temp );
}

这样就会抛出ConcurrentModificationException 异常。 原因:

????? Iterator 是工作在一个独立的线程中,并且拥有一个 mutex 锁。 Iterator 被创建之后会建立一个指向原来对象的单链索引表,当原来的对象数量发生变化时,这个索引表的内容不会同步改变,故当索引指针往后移动的时候就找不到要迭代的对象,按照 fail-fast 原则 Iterator 会马上抛出 java.util.ConcurrentModificationException 异常。
?????? Iterator 在工作的时候是不允许被迭代的对象被改变的。可以使用 Iterator 本身的方法 remove() 来删除对象即:

?Iterator<PowerInfo> it = list.iterator();
??? ??? while( it.hasNext() ){
?????????? PowerInfo temp = it.next();
??? ??? ??? if ( it.next.getName().equals(“teset”) ){
??? ?? ??? ??? it.remove;????? //从迭代器指向的集合中移除迭代器返回的最后一个元素,即移除当前的元素。
}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
不能直接用   File file = new File("http://127.0.0.1:8080/aa.txt") 来读取,因为网络上的传输协议为HTTP,与
        本地不同,要用URL来读取

       String output="";
        File file = new File("E://bb.txt");     

        URL MyURL = new URL("http://127.0.0.1:8080/aa.txt");
        URLConnection uc=MyURL.openConnection();
        uc.connect();

        InputStreamReader _Input=new InputStreamReader(uc.getInputStream(),"UTF-8");
        BufferedReader br=new BufferedReader(_Input);

        String s="";
        while((s=br.readLine())!=null){
        output+=s;
        }

        FileWriter fw=new FileWriter(file);
        fw.write(output);
        fw.flush();
        fw.close();


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
1, 在得到数据时不用再强制类型转换

      private Map powers = new HashMap();
    
    public void addModule( String moduleId, ModulePower mp ){
        powers.put( moduleId , mp );
        
    }
    
    public ModulePower findModuleById( String moduleId ){
        return powers.get( moduleId ); //自动识别为ModulePower
    }

2, 灵活

public interface List {

           void add(E x);

           Iterator iterator();

}

public interface Iterator {

           E next();

           boolean hasNext();

}
  // E 可为任意类型,可为除类型不一样,其它都一样的多个类提供模版,即提取出公共的类代码部分


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
public class Log{

    private int count;

   static{
        setCount( 1 );  //通过static构造程序块进行初始化,与匿名类的初始化一样.
    }

  private Log(){
    
  }
 
 public setCount( int count ){
    this.count = count;
}
}

注:
   static{
        setCount( 1 );  //通过static构造程序块进行初始化,与匿名类的初始化一样.
        System.out.println( "initialization...' );
        System.exit(0);  //即使没有main函数也能执行
    }


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

如字符串:a.js
以“.”分割为字符串数组时,使用java String.split()的时候
必须经过转义后才能分割,单纯的以jsName.split(“.”);分割时,结构字符串数组长度为0;

而如果使用apche.commons.lang.StringUtils.split()方法 则可以直接使用,对比如下:
String jsName=”a.js”;
String[] splitStr = jsName.split(“\\.”);
splitStr = StringUtils.split(“a.js”, “.”)


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?★ =: 赋值运算符,在编译器将右边的表达式结果计算出来后,和左边的变量类型比较精度,如果左边的变量精度低于右边的结果的精度,编译器会显式的报错,告诉程序员去强制转型。(所以s1 = s1 + 1出错)最后将表达式的结果复制到变量所在的内存区。
= 是会在把后面的数值赋值到前面的变量时检测类型是否相同( 非自动强制转换!)如果是高精度到低精度的,需要报错,告诉程序员会loss of data

★ +=:暂且称之为**运算符,编译器自动隐式直接将+=运算符后面的操作数强制装换为前面变量的类型,然后在变量所在的内存区上直接根据右边的操作数修改左边变量内存存储的二进制数值(所以 s += 1不报错)最后达到和赋值运算符相同的目的。与前者相比,由于后者是位操作,效率也较前者高。+= 会把后面的数值自动强制转换为前面的类型,不管类型谁大谁小,然后在那快内存上直接修改数值


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

我们在使用toArray()方法的时候,通常会遇到转型无值的问题,例如:

List widgetList = new ArrayList();
String[]? widgetArray = (String[])widgetList.toArray();

?这样的转型很明显是错误的,我们知道,java中转型基本要遵循向上转型的问题
,在这里,如果采用上述转法,widgetArray中将无法转换出正确的值。正确方法
应采用下面:
List widgetList = new ArrayList();
String[]? widgetArray = new String[widgetList.size()];
widgetList.toArray(widgetArray );

其实我们可以把toArray(new String[size])的方法看做是将Object[]全部复制到新的String[]数组中


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1、
字符串转换成数值类型用:
数值类型完整名.parse + 类型名(字符串)例如:
string? str = “20”;
int num = Integer.parseInt(str);

2、
将基本类型转换成字符串
?? string str = string.valueOf(double/int/float…);

3、
将字符串分割成数组string []
str = new string[];
str = 字符串.split(“分割符”)

4、
将数组中的元素组合成字符串
???? (没有此方法)

5、
Java中的方法名小写,类名大些,且类名和文件名相同(及和.java文件名相同)

6、
使用方法的好处:方法可以被反复的调用,从而使代码变得简洁,如果方法带参数则方法变得更加灵活。

7、
如果想打印出引号(“)则需要将引号写成(\”)形式。(\转义工具,也许可以这么说吧)

8、
\n 是换行,\t是8个空格不换行。

9、(正则运算)
String geCi = “这些年一个人,风也过,雨也过,有过泪,有过错,还记得坚持什么,真爱过才会懂,会寂寞会回首,终有梦终有你在心中。朋友一生一起走,那些日子不再有,一句话,一辈子,一生情,一杯酒。朋友不曾孤单过,一声朋友你会懂,还有伤,还要走,还有我。”;
??int i = 0;
??int j= 0;
??String b = “朋友”;
??for(i=0;i<geCi.length();i++){
???if(b.regionMatches(0, geCi, i, 2)){
????j++;
???}
??}
??System.out.println(“\”朋友\”共出现” + j + “次”);

?}
10、
(int)char方法可以将char类型的变量转变成int类型(及将汉字转换成其在计算机中相应的内码,整型,将小写字母转换成大写字母的的方法是:(char)((int)字母 – 32))
在如下方法中是正确的,如果是double类型的则不可以
public? int count(char c,int i)
?return c*i;
?(重要)
11、
str1.equals(str2)方法可以比较如下的string类型的字符串
String str1 = new String(“str”);
String str2 = new String(“str”);
System.out.println(str1.equals(str2));
输出的值为true;

String str1 = “str”;
String str2 = new String(“str”);
System.out.println(str1.equals(str2));
输出的值为true;

String str1 = “str”;
String str2 = “str”;
System.out.println(str1.equals(str2));
输出的值为true;

“==”只能用与一下的以中形式:
String str1 = “str”;
String str2 = “Str”;
System.out.println(str1==str2);
输出的值为true;

12、
int i =1;
i++;
(1)System.out.println(i);
结果为:2
若:
(1)System.out.println(i++);
(2)System.out.println(++i);
结果为:(1)1 和 (2)2

13、
产生随机数的方法是 (Math.Random())所产生的随机数在[0-1)之间

14、
public static void main(String[] args) {
??// TODO 自动生成方法存根
??
??StringBuffer name = new StringBuffer(“YangYang”);
??StringBuffer nickName = new StringBuffer(“YaYa”);
??D d = new D();
??d.changeName(name,nickName);
??System.out.print(“? “+name);
??System.out.println(“? ” + nickName);
??
??
?}
?public void changeName(StringBuffer name,StringBuffer nickName) ?{
??name = new StringBuffer(“Yangfan”);
??nickName.append(“1”);
??System.out.print(“? “+name);
??System.out.println(“? ” + nickName);
?}
输出结果为: Yangfan? YaYa1? YangYang? YaYa1

25)?使用C#开发控制台应用程序的时候,如果需要程序接收用户输入的整型数字,则应当使用以下(D)语fsdfsdf句实现。(选择一项)
A、?int I = Console.ReadLine().int();? B、int I = int(Console.ReadLine());
C、int I = Console.ReadLine();?? D、int I = int.Parse(Console.ReadLine());

32)?在C#中,下列代码的运行结果是(d)
Using System;
Namespace TestApplication
{?Public class Test
?{Static void Main()
??{?? int x = 6;
???switch(x){
case 6:
case7:
?Console.WriteLine(“今天是周末”);
?Break;
Case 1:
?Console.WriteLine(“今天是星期一”);
?Break;
Case 2:
?Console.WriteLine(“今天是星期二”);
?Break;
Default:
?Console.WriteLine(“你完成任务了吗?”);
?Break;
}
}
}
}
A、?编译错误????????? B、输出:今天星期一?
C、输出:今天星期二?? D、输出今天是周末
39)?给定如下Java代码片段,编译运行时的结果是(D)(选择一项)
Int i = 2;
Switch (i) {
?Default:
?System.out.println (“default”);
Case 0:
System.out.println (“Zero”);
?Break;
Case 1:
?System.out.println (“one”);
?Break;
Case 2:
?System.out.println (“two”);
?Break;
}
A、?输出:default
B、?输出:default
Zero
C、?编译出错,default语句的位置不符合switch结构的语法结构
D、?输出:two

41) 在Java中,下面(AB)语句能够正确通过编译。(选择两项)
?A、System.out.println (1+1);
?B、char i= 2+’2’;
??System.out.println (i);
?C、String s = “on”+’one’; ?D、int b = 255.0;

44) 分析下面的HTML代码片段,则选项中说法正确的是(AD)(选择两项)
?<table cellspcaing=”30”>
?<tr><td colspan=”2” align=”center”>姓名</td></tr>
?<tr><td colspan=”2” align=”center”>成绩</td></tr>
?<tr><td colspan=”2” align=”center”>语文</td></tr>
?<tr><td colspan=”2” algin=”center>数学</td></tr>
?</table>
?该表格共有两行三列?????? B、该表格的边框宽度为30像素
A、?该表格中的文字均A居中显示? D、“姓名”单元格跨2列
45) 在SQL Server 2005数据库中,客户表customers包含字段:客户编号cid和名称cname,订单表orders包含字段:客户编号cid,如果需要通过查询或得订单的客户名称,下面查询语句中(B)可以实现该需求(选择一项)
?A、 select customers.cname from customers left join orders on customers.cid = orders.cid
?B、 select customers.cname from customers inner join orders on customers.cid = orders.cid
?C、select cusomers.cname from customers right join orders where customers.cid = orders.cid
?D、select customers.cname from customers join orders where customers.cid = orders.cid

47)分析下面的Java程序,编译运行结果是(A)(选择一项)
?Public class B{
??Public static void main (String [] args) {
???String s = “y”;
???System.out.println(s+1+2);
???System.out.println (1+2+s);
}
}
A、?输出:y12
3y
B、?输出:y12
12y
C、?输出:y3
3y
D、?程序编译出错
注:String 类的方法对字符串进行操作,没改变一次值,就重新开辟一块内存空间来存储
??? StringBuffer 类的方法是对内存中的值进行处理(在同一块内存空间进行反复的操作,没有重新开辟内存空间)
??? (StringBuffer的方法对字符串的处理比String的方法对字符串的处理的效率高。String 可以不用new关键字创建对象,它会自动的隐式创 建,String- Buffer必须用new关键字)

? 例如:
??? string str = “我”;
??? str.concat(“们”);????? //操作的仅是副本,并没将值复制给str
??? syso(str);
??? 结果为:我,而并非,我们;
??? 而
??? StringBuffer sb = new StringBuffer(“我”);
??? sb.compend(“们”);????? //直接修改内存中的值
??? syso(sb);
??? 结果为:我们,而并非,我;