Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中,将值从一个void函数传递到另一个void函数_Java - Fatal编程技术网

在java中,将值从一个void函数传递到另一个void函数

在java中,将值从一个void函数传递到另一个void函数,java,Java,我是X班的学生。我正在用java做一个学校项目。我被困在这里的某个地方。我的代码如下 package school.PRo; import java.util.Scanner; class Telephone_Bill { String c_name[]=new String[10]; String c_add[]=new String[10]; String phno[]=new String[10

我是X班的学生。我正在用java做一个学校项目。我被困在这里的某个地方。我的代码如下

package school.PRo;
    import java.util.Scanner;
    class Telephone_Bill
       {
           String c_name[]=new String[10];
           String c_add[]=new String[10];
           String phno[]=new String[10];
           void accept(int n)
                {
                     Telephone_Bill ob=new Telephone_Bill();
                    Scanner in=new Scanner(System.in);
                      int i;
                     String name[]=new String[10];
                     String add[]=new String[10];
                     String ph[]=new String[10];
                     for(i=0;i<n;i++)
                        {
                            System.out.println("Index Number:>>"+i+1);
                            System.out.print("Enter The name of the customer:>>");
                            name[i]=in.nextLine();
                            c_name[i]=name[i];
                            System.out.print("Enter The address of the customer:>>");
                            add[i]=in.nextLine();
                            c_add[i]=add[i];
                            System.out.print("Enter The phone number of the customer:>>");
                            ph[i]=in.nextLine();
                            phno[i]=ph[i];
                        }
                        ob.show(n);
                    }
                    static void main(String args[])
                        {
                            int n;
                            Scanner in=new Scanner(System.in);
                            Telephone_Bill ob=new Telephone_Bill();
                            System.out.print("Enter the no. of customer:>");
                            n=in.nextInt();
                            ob.accept(n);
                        }
                    void show()
                        {
                            int i=0,p;
                            while(i<p)
                                {
                                    System.out.print(c_name[i]+" "+c_add[i]+" "+phno[i]);
                                }
                            }
                        }
package school.PRo;
导入java.util.Scanner;
班级电话费
{
字符串c_name[]=新字符串[10];
字符串c_add[]=新字符串[10];
字符串phno[]=新字符串[10];
无效接受(整数n)
{
电话账单ob=新电话账单();
扫描仪输入=新扫描仪(系统输入);
int i;
字符串名称[]=新字符串[10];
字符串添加[]=新字符串[10];
字符串ph[]=新字符串[10];

对于(i=0;i,需要向show()方法添加一个参数


当你把一个参数传递给一个函数时,这个函数声明应该有一个可以实际接受它的参数。你在这里缺少它

void show() {
}
当您更改方法时,将显示为

void show(int arg)
现在,您的方法show可以在变量arg

void声明,方法show不返回任何内容。它与传递的参数无关


阅读更多信息

请提供一个错误我在Sun Java论坛上学会了破译这些帖子…:)当你将一个参数传递给另一个函数时,另一个函数声明应该有一个可以实际接受它的参数。你在这里丢失了它。
void show(int arg)