Home > Back-end >  O bosses to see!!!!!!!!!!!!!!!!!!!!!!!!!!
O bosses to see!!!!!!!!!!!!!!!!!!!!!!!!!!

Time:10-13

Define a generic class (Miami) In the create two classes (Detroit and Philadelphia) inherited the generic class
This should be how to write ah bosses
The class Miami
{
The class Detroit;
Public Miami (String Detroit)
{
This. Detroit=Detroit;
}
The class at Philadelphia;
Public Miami (String Philadelphia)
{
This. Philadelphia=Philadelphia;
}
}
For big solutions

CodePudding user response:

How to write this????????????

CodePudding user response:

Package GenericProgramma;

The class Miami
{
Private [T] Detroit;
Private [T] Philadelphia;
Detroit public Miami (T [], T [] Philadelphia)
{
This. Detroit=Detroit;
This. Philadelphia=Philadelphia;
}

Public Miami (String [] info)
{

}

Public void showBookInfo ()
{
System. The out. Println (" the name of the bank account \ \ t \ \ t deposit time t \ \ t t currency deposit amount t account balance ");
for (int i=0; I & lt; Detroit. Length; I++)
{
System. The out. Print (Detroit [I] + "\ t");
}
}
Public void showBookInfo1 ()
{
System. The out. Println (" the name of the bank account \ \ t \ \ t deposit time t \ \ t t currency deposit amount t account balance ");
for (int i=0; i{
System. The out. Print (Philadelphia [I] + "\ t");
}
}
Public static void main (String [] args)
{
String [] info={" zhang ", "Rmb", "8888.00 Rmb", "18888.88 Rmb"};
String [] info1={" zhang ", "Rmb", "8888.00 Rmb", "18888.88 Rmb"};
Miami Bank=new Miami (info);
Miami Bank1=new Miami (info1);
Bank showBookInfo ();
Bank1. ShowBookInfo1 ();

}
}
This is after I wrote, the error
The name of the bank time deposit account currency deposit account balance
The Exception in the thread "main" Java. Lang. NullPointerException
The at GenericProgramma. Miami. ShowBookInfo (Arbitrarily. Java: 21)
The at GenericProgramma. Miami. The main (Arbitrarily. Java: 40)
This is what reason!
prompt
  • Related