「java显示函数」java里的函数
今天给各位分享java显示函数的知识,其中也会对java里的函数进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、JAVA中判断字符是否可以显示的函数!
- 2、Java中用show函数为什么显示不出来,知道这是个过时的函数,有其他显示函数用吗???
- 3、java怎样编写show函数实现数据的显示操作
- 4、java定义一个点类(point),包含x,y坐标数据成员,显示函数(show)和计算面积(getarea)的函数成员
- 5、java控制台不显示被调用的函数结果
JAVA中判断字符是否可以显示的函数!
java.lang.Character类有很多静态方法可以测试字符的类型,不过没有直接判断是否可显示。我帮你测试了一下,只有isWhitespace比较适合你,所有控制字符,都返回true,不过空格也返回true。你可以自己判断以下
if(ch!=' 'Character.isWhitespace(ch)) 为真则是不可显示字符
如果不满足你的要求,你可以自己看看这个类的其他方法
Java中用show函数为什么显示不出来,知道这是个过时的函数,有其他显示函数用吗???
用show()是可以显示的,看你显示容器的时候使用什么样的布局方式;如果在布局的时候用CardLayout布局,就可以用show()来显示组件;(请注意下面例子的加粗字体部分)import java.awt.*;
import java.awt.event.*;
public class Tqq extends Frame implements ActionListener{
Label l1,l2,l3,l4;
Button b1,b2,b3;
CardLayout card;
Panel p;
Tqq(){
l1=new Label("第一张");
l2=new Label("第二张");
l3=new Label("第三张");
l4=new Label("第四张");
b1=new Button("第一张");
b2=new Button("下一张");
b3=new Button("最后一张");
p=new Panel();
card=new CardLayout();
p.setLayout(card);
p.setBackground(Color.pink);
p.add("0",l1);
p.add("1",l2);
p.add("2",l3);
p.add("3",l4);
Panel pp=new Panel();
pp.add(b1);
pp.add(b2);
pp.add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
add(p,BorderLayout.NORTH);
add(pp,BorderLayout.SOUTH);
setVisible(true);
setBounds(300,300,300,200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent ee){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1){
card.show(p,"0");
}
else if(e.getSource()==b2){
card.next(p);
}
else if(e.getSource()==b3){
card.show(p,"3");
}
}
public static void main(String [] agr){
new Tqq();
}
}
java怎样编写show函数实现数据的显示操作
package math; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Toolkit; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JComboBox; import javax....
java定义一个点类(point),包含x,y坐标数据成员,显示函数(show)和计算面积(getarea)的函数成员
import java.lang.Math.*;
class point {
int x;
int y;
void show()
{
//don't know the purpose for this one.
}
double getarea()
{
return Math.sqrt(y*y + x*x);
}
}
class circirl extends point
{
int r;
double getarea(int r)
{
return (3.14*r*r);
}
}
public class line {
point point1;
point point2;
int getarea(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
return Math.abs(width)*Math.abs(length);
}
double length(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
double leng_point = Math.sqrt(length*length + width*width);
return leng_point;
}
public static void main(String[] args) {
line line =new line();
// circirl circirl = new circirl();
line.point1 = new point();
line.point1.x= 40;
line.point1.y= 40;
line.point2 = new point();
line.point2.x= 70;
line.point2.y= 90;
int len = line.getarea(line.point1,line.point2);
System.out.println("the len for the two point is "+len);
double sqre = line.length(line.point1,line.point2);
System.out.println("the squre for the two point is "+sqre);
}
}
java控制台不显示被调用的函数结果
由于jvm在运行这个java应用程序的时候,首先会调用main方法,调用时不实例化这个类的对象,而是通过类名直接调用因此需要是限制为publicstatic。对于java中的main方法,jvm有限制,不能有返回值,因此返回值类型为void。所以是不会显示函数结果的。
关于java显示函数和java里的函数的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。