|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
中间码是基于一个虚拟机器。源代码是最高层的,理论上从源代码开始直接编译成本地码能提供最大优化的。而中间码只能是转译成本地码,效率上难免受到损耗。根据虚拟机器所设定的体系结构的特点,和本地机器的差异的多少。未几说了,间接上源码:
usingSystem;
usingSystem.Drawing;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Windows.Forms;
usingSystem.Data;
namespaceWindowsApplication1
{
publicclassForm1:System.Windows.Forms.Form
{
privateSystem.Windows.Forms.TextBoxtextBox1;
privateSystem.Windows.Forms.TextBoxtextBox2;
privateSystem.Windows.Forms.Buttonbutton1;
privateSystem.ComponentModel.Containercomponents=null;
publicForm1()
{
InitializeComponent();
}
protectedoverridevoidDispose(booldisposing)
{
if(disposing)
{
if(components!=null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
privatevoidInitializeComponent()
{
this.textBox1=newSystem.Windows.Forms.TextBox();
this.textBox2=newSystem.Windows.Forms.TextBox();
this.button1=newSystem.Windows.Forms.Button();
this.SuspendLayout();
this.textBox1.Location=newSystem.Drawing.Point(8,32);
this.textBox1.Multiline=true;
this.textBox1.Name="textBox1";
this.textBox1.ScrollBars=System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size=newSystem.Drawing.Size(176,344);
this.textBox1.TabIndex=0;
this.textBox1.Text="";
this.textBox2.Location=newSystem.Drawing.Point(328,32);
this.textBox2.Multiline=true;
this.textBox2.Name="textBox2";
this.textBox2.ScrollBars=System.Windows.Forms.ScrollBars.Both;
this.textBox2.Size=newSystem.Drawing.Size(168,344);
this.textBox2.TabIndex=1;
this.textBox2.Text="";
this.button1.Location=newSystem.Drawing.Point(216,8);
this.button1.Name="button1";
this.button1.TabIndex=2;
this.button1.Text="词频统计";
this.button1.Click+=newSystem.EventHandler(this.button1_Click);
this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);
this.ClientSize=newSystem.Drawing.Size(512,397);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Name="Form1";
this.Text="Form1";
this.ResumeLayout(false);
}
[STAThread]
staticvoidMain()
{
Application.Run(newForm1());
}
privatevoidbutton1_Click(objectsender,System.EventArgse)
{
strings=textBox1.Text;
char[]c={,,,.,?,,:,;,!};
string[]ss=s.Split(c);
Hashtableha=newHashtable();
foreach(stringsssinss)
{
if(ha.Contains(sss))
{
ha[sss]=(int)ha[sss]+1;
}
else
{
ha.Add(sss,1);
}
}
foreach(DictionaryEntrydeinha)
{
textBox2.AppendText(de.Key+":"+de.Value+"
");
}
}
}
}
归根到底,Java跨平台可以,但是要重新编写代码,否则还分什么J2EE/J2SE/J2ME呢! |
|