import java.awt.*;
importjava.awt.*;importjava.applet.*;publicclassStringDemoextendsApplet{Stringstr1="s...
import java.awt.*;
import java.applet.*;
public class StringDemo extends Applet{
String str1="student";
String str2=new String("china");
char a[]={'t','e','a','c','h','e','r'};
String str3=new String(a);
String str4=new String(a,2,4);
byte b[]={97,98,99,100,101};
String str5=new String(b);
public void paint(Graphics g){
g.drawString("str1="+str1,20,20);
g.drawString("str2="+ );
g.drawString("str3="+);
g.drawString("str4="+);
g.drawString("str5="+);
g.drawString("str1的长度为"+);
g.drawString("str2的第2个字符为"+);
g.drawString("str2转化为大写为"+);
g.drawString("ch在str3中的位置为"+);
g.drawString("str4的前缀与ac比较的结果为"+);
g.drawString("str5的第2个位置开始长度为2的子串为:"+);
}
}
把此Java程序补充完整 展开
import java.applet.*;
public class StringDemo extends Applet{
String str1="student";
String str2=new String("china");
char a[]={'t','e','a','c','h','e','r'};
String str3=new String(a);
String str4=new String(a,2,4);
byte b[]={97,98,99,100,101};
String str5=new String(b);
public void paint(Graphics g){
g.drawString("str1="+str1,20,20);
g.drawString("str2="+ );
g.drawString("str3="+);
g.drawString("str4="+);
g.drawString("str5="+);
g.drawString("str1的长度为"+);
g.drawString("str2的第2个字符为"+);
g.drawString("str2转化为大写为"+);
g.drawString("ch在str3中的位置为"+);
g.drawString("str4的前缀与ac比较的结果为"+);
g.drawString("str5的第2个位置开始长度为2的子串为:"+);
}
}
把此Java程序补充完整 展开
2个回答
展开全部
import java.awt.*;
import java.applet.Applet;
import java.awt.*;
import java.applet.Applet;
public class StringDemo extends Applet {
String str1 = "student";
String str2 = new String("china");
char a[] = { 't', 'e', 'a', 'c', 'h', 'e', 'r' };
String str3 = new String(a);
String str4 = new String(a, 2, 4);
byte b[] = { 97, 98, 99, 100, 101 };
String str5 = new String(b);
public void paint(Graphics g) {
// 在java中字符串是从0开始的,不知道楼主说的位置是以0为标准还是以1为标准的,这里是以0为标准
g.drawString("str1=" + str1, 20, 20);
g.drawString("str2=" + str2, 20, 35);
g.drawString("str3=" + str3, 20, 50);
g.drawString("str4=" + str4, 20, 65);
g.drawString("str5=" + str5, 20, 80);
g.drawString("str1的长度为:" + str1.length(), 20, 95);
g.drawString("str2的第2个字符为" + str2.charAt(2), 20, 110);
g.drawString("str2转化为大写为" + str2.toUpperCase(), 20, 125);
g.drawString("ch在str3中的位置为" + str3.indexOf("ch"), 20, 140);
g.drawString("str4的前缀与ac比较的结果为" + str4.startsWith("ac"),20, 155);
g.drawString("str5的第2个位置开始长度为2的子串为:" + str5.substring(2, 4), 20, 170);
}
}
// 在java中字符串是从0开始的,不知道楼主说的位置是以0为标准还是以1为标准的,这里是以0为标准
import java.applet.Applet;
import java.awt.*;
import java.applet.Applet;
public class StringDemo extends Applet {
String str1 = "student";
String str2 = new String("china");
char a[] = { 't', 'e', 'a', 'c', 'h', 'e', 'r' };
String str3 = new String(a);
String str4 = new String(a, 2, 4);
byte b[] = { 97, 98, 99, 100, 101 };
String str5 = new String(b);
public void paint(Graphics g) {
// 在java中字符串是从0开始的,不知道楼主说的位置是以0为标准还是以1为标准的,这里是以0为标准
g.drawString("str1=" + str1, 20, 20);
g.drawString("str2=" + str2, 20, 35);
g.drawString("str3=" + str3, 20, 50);
g.drawString("str4=" + str4, 20, 65);
g.drawString("str5=" + str5, 20, 80);
g.drawString("str1的长度为:" + str1.length(), 20, 95);
g.drawString("str2的第2个字符为" + str2.charAt(2), 20, 110);
g.drawString("str2转化为大写为" + str2.toUpperCase(), 20, 125);
g.drawString("ch在str3中的位置为" + str3.indexOf("ch"), 20, 140);
g.drawString("str4的前缀与ac比较的结果为" + str4.startsWith("ac"),20, 155);
g.drawString("str5的第2个位置开始长度为2的子串为:" + str5.substring(2, 4), 20, 170);
}
}
// 在java中字符串是从0开始的,不知道楼主说的位置是以0为标准还是以1为标准的,这里是以0为标准
展开全部
import java.awt.*;
import java.applet.Applet;
public class StringDemo extends Applet {
private static final long serialVersionUID = 1L;
String str1 = "student";
String str2 = new String("china");
char a[] = { 't', 'e', 'a', 'c', 'h', 'e', 'r' };
String str3 = new String(a);
String str4 = new String(a, 2, 4);
byte b[] = { 97, 98, 99, 100, 101 };
String str5 = new String(b);
public void paint(Graphics g) {
g.drawString("str1=" + str1, 20, 20);
g.drawString("str2=" + str2, 20, 35);
g.drawString("str3=" + str3, 20, 50);
g.drawString("str4=" + str4, 20, 65);
g.drawString("str5=" + str5, 20, 80);
g.drawString("str1的长度为:" + str1.length(), 20, 95);
g.drawString("str2的第2个字符为" + str2.charAt(2), 20, 110);
g.drawString("str2转化为大写为" + str2.toUpperCase(), 20, 125);
g.drawString("ch在str3中的位置为" + str3.indexOf("ch"), 20, 140);
g.drawString("str4的前缀与ac比较的结果为" + str4.startsWith("ac"), 20, 155);
g.drawString("str5的第2个位置开始长度为2的子串为:" + str5.substring(2, 4), 20, 170);
}
}
import java.applet.Applet;
public class StringDemo extends Applet {
private static final long serialVersionUID = 1L;
String str1 = "student";
String str2 = new String("china");
char a[] = { 't', 'e', 'a', 'c', 'h', 'e', 'r' };
String str3 = new String(a);
String str4 = new String(a, 2, 4);
byte b[] = { 97, 98, 99, 100, 101 };
String str5 = new String(b);
public void paint(Graphics g) {
g.drawString("str1=" + str1, 20, 20);
g.drawString("str2=" + str2, 20, 35);
g.drawString("str3=" + str3, 20, 50);
g.drawString("str4=" + str4, 20, 65);
g.drawString("str5=" + str5, 20, 80);
g.drawString("str1的长度为:" + str1.length(), 20, 95);
g.drawString("str2的第2个字符为" + str2.charAt(2), 20, 110);
g.drawString("str2转化为大写为" + str2.toUpperCase(), 20, 125);
g.drawString("ch在str3中的位置为" + str3.indexOf("ch"), 20, 140);
g.drawString("str4的前缀与ac比较的结果为" + str4.startsWith("ac"), 20, 155);
g.drawString("str5的第2个位置开始长度为2的子串为:" + str5.substring(2, 4), 20, 170);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询