toUpperCase()把字符串大写
intern()返回一个标准的String格式toUpperCase().intern() 就是返回一个标准的大写字符串。

解决方案 »

  1.   

    toUpperCase()是指转换为大写
    intern()是可以用来提高String的效率
    eg:
    1. String s1="abc",s2="abc";
    s1==s2;//true
    String s1="abc",s2=new String("abc";)
    s1==s2;//false
    解:当编译器在源代码中遇到"abc"时,将其放入常量缓冲区中,但如果编译器遇到该字符串的第二个副本,就不将其放入常量缓冲区中,而是产生字节码指定来引用第一个字符串常量,在运行时当s1和s2都被赋值为对字符串对象(加载类文件时创建)的引用,它们实际指向包含"abc"的同一String对象。
    通常缓冲区中的由字符串常量创建的字符串对象是固定的,即这些字符串对象保存在包含唯一字符串(即字符串带唯一的字符序列)内存缓冲区中,String类对这个内存缓冲区进行维护,只有两种方法可以固定String
    一,在源代码中使用String常数。二,使用String的intern方法。
    eg:String s1="abc",s2=new String ("abc").intern;
    s1==s2;//true
    下面给出整个源代码
    public class StringTest{
    public static void main(String[] args){
    String s1,s2,s3,s4;
    s1="abc";
    s2="abc";
    s3=new String("abc");
    s4=new String("abc").intern();
    System.out.println(s1==s2);
    System.out.println(s1==s3);
    System.out.println(s1==s4);
    }
    }
      

  2.   

    **********************************
    // Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
    // Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
    // Decompiler options: packimports(3) fieldsfirst ansi 
    // Source File Name:   PasswdLevel4.javaimport java.applet.Applet;
    import java.applet.AppletContext;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.EventObject;public class PasswdLevel4 extends Applet
        implements ActionListener
    {    private URL finalurl;
        String infile;
        String inuser[];
        int totno;
        InputStream countConn;
        BufferedReader countData;
        URL inURL;
        TextField txtlogin;
        Label label1;
        Label label2;
        Label label3;
        TextField txtpass;
        Label lblstatus;
        Button ButOk;
        Button ButReset;
        Label lbltitle;    public PasswdLevel4()
        {
            inuser = new String[22];
            totno = 0;
            countConn = null;
            countData = null;
            inURL = null;
            txtlogin = new TextField();
            label1 = new Label();
            label2 = new Label();
            label3 = new Label();
            txtpass = new TextField();
            lblstatus = new Label();
            ButOk = new Button();
            ButReset = new Button();
            lbltitle = new Label();
        }    void ButOk_ActionPerformed(ActionEvent actionevent)
        {
            boolean flag = false;
            for(int i = 1; i <= totno / 2; i++)
                if(txtlogin.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 2].trim().toUpperCase().intern() && txtpass.getText().trim().toUpperCase().intern() == inuser[2 * (i - 1) + 3].trim().toUpperCase().intern())
                {
                    lblstatus.setText("Login Success, Loading..");
                    flag = true;
                    String s = inuser[1].trim().intern();
                    String s1 = getParameter("targetframe");
                    if(s1 == null)
                        s1 = "_self";
                    try
                    {
                        finalurl = new URL(getCodeBase(), s);
                    }
                    catch(MalformedURLException _ex)
                    {
                        lblstatus.setText("Bad URL");
                    }
                    getAppletContext().showDocument(finalurl, s1);
                }        if(!flag)
                lblstatus.setText("Invaild Login or Password");
        }    void ButReset_ActionPerformed(ActionEvent actionevent)
        {
            txtlogin.setText("");
            txtpass.setText("");
        }    public void actionPerformed(ActionEvent actionevent)
        {
            Object obj = actionevent.getSource();
            if(obj == ButOk)
            {
                ButOk_ActionPerformed(actionevent);
                return;
            }
            if(obj == ButReset)
                ButReset_ActionPerformed(actionevent);
        }    public void destroy()
        {
            ButOk.setEnabled(false);
            ButReset.setEnabled(false);
            txtlogin.setVisible(false);
            txtpass.setVisible(false);
        }    public void inFile()
        {
            new StringBuffer();
            try
            {
                countConn = inURL.openStream();
                countData = new BufferedReader(new InputStreamReader(countConn));
                String s;
                while((s = countData.readLine()) != null) 
                    if(totno < 21)
                    {
                        totno = totno + 1;
                        inuser[totno] = s;
                        s = "";
                    } else
                    {
                        lblstatus.setText("Cannot Exceed 10 users, Applet fail start!");
                        destroy();
                    }
            }
            catch(IOException ioexception)
            {
                getAppletContext().showStatus("IO Error:" + ioexception.getMessage());
            }
            try
            {
                countConn.close();
                countData.close();
                return;
            }
            catch(IOException ioexception1)
            {
                getAppletContext().showStatus("IO Error:" + ioexception1.getMessage());
            }
        }    public void init()
        {
            setLayout(null);
            setSize(361, 191);
            add(txtlogin);
            txtlogin.setBounds(156, 72, 132, 24);
            label1.setText("Please Enter Login Name & Password");
            label1.setAlignment(1);
            add(label1);
            label1.setFont(new Font("Dialog", 1, 12));
            label1.setBounds(41, 36, 280, 24);
            label2.setText("Login");
            add(label2);
            label2.setFont(new Font("Dialog", 1, 12));
            label2.setBounds(75, 72, 36, 24);
            label3.setText("Password");
            add(label3);
            add(txtpass);
            txtpass.setEchoChar('*');
            txtpass.setBounds(156, 108, 132, 24);
            lblstatus.setAlignment(1);
            label3.setFont(new Font("Dialog", 1, 12));
            label3.setBounds(75, 108, 57, 21);
            add(lblstatus);
            lblstatus.setFont(new Font("Dialog", 1, 12));
            lblstatus.setBounds(14, 132, 344, 24);
            ButOk.setLabel("OK");
            add(ButOk);
            ButOk.setFont(new Font("Dialog", 1, 12));
            ButOk.setBounds(105, 156, 59, 23);
            ButReset.setLabel("Reset");
            add(ButReset);
            ButReset.setFont(new Font("Dialog", 1, 12));
            ButReset.setBounds(204, 156, 59, 23);
            lbltitle.setAlignment(1);
            add(lbltitle);
            lbltitle.setFont(new Font("Dialog", 1, 12));
            lbltitle.setBounds(12, 14, 336, 24);
            String s = getParameter("title");
            lbltitle.setText(s);
            ButOk.addActionListener(this);
            ButReset.addActionListener(this);
            infile = new String("level4");
            try
            {
                inURL = new URL(getCodeBase(), infile);
            }
            catch(MalformedURLException _ex)
            {
                getAppletContext().showStatus("Bad Counter URL:" + inURL);
            }
            inFile();
        }
    }
    *****************************************
    这位大哥   你在这段代码中能知道 txtlogin和txtpass.setText的值吗?
    或者是一个连接什么的   我想知道这个。CLASS是起什么作用的
    谢谢   完事就给分