JAVA基础

来源:互联网 发布:51单片机手动复位电路 编辑:程序博客网 时间:2024/06/16 17:29
1、IDE:IDE (Integrated Development Environment) 集成开发环境
集成开发环境(简称IDE)软件是用于程序开发环境的应用程序,一般包括代码编辑器、编译器、调试器和图形用户界面工具。就是集成了代码编写功能、分析功能、编译功能、debug功能等一体化的开发软件套。所有具备这一特性的软件或者软件套(组)都可以叫做IDE。如微软的Visual Studio系列,Borland的C++ Builder,Delphi系列等。该程序可以独立运行,也可以和其它程序并用。例如,BASIC语言在微软办公软件中可以使用,可以在微软Word文档中编写WordBasic程序。IDE为用户使用Visual Basic、Java和PowerBuilder等现代编程语言提供了方便。 不同的技术体系有不同的IDE。比如visual studio.Net可以称为C++、VB、C#等语言的集成开发环境,所以visual studio.Net可以叫做IDE。同样,Borland的JBuilder也是一个IDE,它是Java的IDE。zend studio、editplus、ultra edit这些,每一个都具备基本的编码、调试功能,所以每一个都可以称作IDE。
IDE多被用于开发HTML应用软件。例如,许多人在设计网站时使用IDE(如HomeSite、DreamWeaver、FrontPage,等等),因为很多项任务会自动生成。IDE集成代码编辑,代码生成,界面设计,调试,编译等功能,目前还融合了建模功能。


2、标识符号命名规则:类名:开头首字母必须大写,可以字母开头.也可以下划线开头、数字和中文,以字母、美元符号、下划线开头,后面的下划线可以是字母、数字、下划线或者美元符号。不能以关键字作为标识符。


3、程序入口:
public static void main(String[]args){
//程序入口
4、删除项目、导出/导入项目。
删除项目:Delete projrct contents on disk  删除本地文件(源文件)
导出/导入项目:Copy projects into workspace 复制到当前工作集(源文件copy)

5、a:菜单快捷键:Alt+shift+N。
  b:ctrl+shift+r:打开资源
           c:ctrl+o:快速outline
  d:ctrl+e:快速转换编辑器 
  e:ctrl+2,L:为本地变量赋值
  f:alt+shift+r:重命名
  g:alt+shift+l以及alt+shift+m:提取本地变量及方法
  h:ctrl+.及ctrl+1:下一个错误及快速修改


6、Web:a:默认端口为80;
      b:www 80/tcp #http
`
7、一个文件类里只能有一个public类

  所有非byte类型的基本类型都可以通过String.valueOf() 方法来转换为         

 字符串非基本类型的比较需要使用equals方法



----------------------------------------------------------------------------------------------------------------

//网页的邮箱


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script>
var password=0;
function  showName(){ /*判断用户输入的名字是否为空*/

var name=document.getElementById("name").value;
//name=trim(name);
if(name==""){

document.getElementById("nameFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的名字为空</div>";
}else{
document.getElementById("nameFont").innerHTML="<img src ='image/right.jpg'/>";
}
}

function  showEmil(){ /*判断用户输入的EMIL是否为合格*/
var emil=document.getElementById("emil").value;
var rightEmli = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
var isright=rightEmli.test(emil);
//name=trim(name);
if(emil==""){

document.getElementById("emilFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的邮箱为空</div>";
}else if(!isright){/*验证是否符合邮箱格式没有起作用*/
//alert(rightEmil.test(emil));
document.getElementById("emilFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的邮箱格式有误</div>";

}else{
document.getElementById("emilFont").innerHTML="<img src ='image/right.jpg'/>";
}
}

function  showPwd(){ /*判断用户输入的密码是否为空*/

var pwd=document.getElementById("pwd").value;
//name=trim(name);
if(pwd==""){

document.getElementById("pwdFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的密码为空</div>";
}else{
document.getElementById("pwdFont").innerHTML="<img src ='image/right.jpg'/>";
password=pwd;
}
}
function  showNextPwd(){ /*判断用户输入的密码是否和上次的一样||是否为空*/

var nextpwd=document.getElementById("nextpwd").value;
//name=trim(name);
if(nextpwd==""){

document.getElementById("nextpwdFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的密码为空</div>";
}else if(password!=nextpwd){
document.getElementById("nextpwdFont").innerHTML="<img src ='image/wrong.jpg' style='margin-top:0px;'/><div style='color:red;margin-top:-19px;font-size:10px;margin-left:30px;'>你输入的密码不一致</div>";

}else{
document.getElementById("nextpwdFont").innerHTML="<img src ='image/right.jpg'/>";
}
}
</script>  
  </head>
  
  <body> 
  <center>
    <h1 style ="color:red;font-size:60px">用户注册</h1>
    </center>
    <hr></hr>
    <from action="#" method="post">
    <table cellpadding="5">
    <tr>
    <td><span>name:</span></td>
    <td ><input style="width:200px" type="text" value="youe name"  id="name" onfocus="showName()"  onblur="showName()"/></td>
    <td id="nameFont"></td>
    </tr>
    <tr>
    <td><span>emil:</span></td>
    <td><input style="width:200px" type="text" value="@com" id="emil" onfocus="showEmil()"  onblur="showEmil()"/></td>
    <td id="emilFont"></td>
    <tr>
    <td><span>pwd:</span></td>
    <td><input style="width:200px" type="password" value="888" id="pwd" onfocus="showPwd()"  onblur="showPwd()"/></td>
    <td id="pwdFont"></td>
        </tr>
    <tr>
    <td><span>last:</span></td>
    <td><input style="width:200px" type="password" value="777" id="nextpwd" onfocus="showNextPwd()"  onblur="showNextPwd()"/></td>
    <td id="nextpwdFont"></td>
    </tr>
   
    <tr>
    <td>
    <input type="button" value="注册新用户" id ="button"/>
    </td>
    <td>
    </td>
    </tr>
   
    </table>
     <hr></hr>
    </from>
  </body>
</html>

------------------------------------------------------------------------------------------------------------------------------------

//阶乘的计算

// Scanner input = new Scanner(System.in);
// double num = input.nextInt();
// double sum = 0;
// for(int i=0;i<=num;i++){
// sum+=sum*getNum(i);
// }
// System.out.println(sum);
// }
//
//public static double getNum(int num){
// if(num==1){
// return num;
// }else{
// return num*getNum(num-1);
// }
//

--------------------------------------------------------------------------------------------------------------------------------

三角形布局

// char ch = 'A';
// int line = 20;
// for(int i = 1;i <= 20;i++){
// if(i == 1){
// for(int j = 1;j <= 2*(20 - i) - 1;j++){
// System.out.print(" ");
// }
// }else{
// for(int j = 1;j <= 2*(20 - i);j++){
// System.out.print(" ");
// }
// }
//
// if(i == 1){
// System.out.print(ch);
// }else{
// for(int k = 1;k <=2*(i - 1);k++){
// System.out.print(ch + " ");
// }
// }
//
// System.out.println();
//
// ch++;
// }
// }

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


//九九乘法表

// for(int i=1;i<=9;i++){
// for(int j=1;j<=i;j++){
//
// System.out.print(j+"*"+i+"="+(j*i<10?""+j*i:j*i)+"\t");
// }
// System.out.println();
// }


原创粉丝点击