Home > Back-end >  Error code to run a null pointer, a big help
Error code to run a null pointer, a big help

Time:09-17

Public class queue team {
Private car waiting vehicles;
Private car and car position;

The public line up the team () {
Wait for vehicle=car following location=null;
}

Public void team (Object) {

Car p=new car (license);

If (license plate!=null) {
p=with car position. Next;
With the car position=p;
}
The else {
Wait for vehicle=car following location=p;
}
}

Public Object out of the team () {
If (wait for vehicle!=null) {
P=waiting vehicles;
Waiting for vehicles. Vehicle=next;
If (p==with car location)
With the car position=null;
Return p. license plate;
}
The else {
return null;
}

}

}

Red mark this line is marked the wrong place, how to solve ah

CodePudding user response:

With car position is null, then you call last get-together with car position the uninitialized variables, you just declare the variable, the virtual machine to help you create the object is null, not point to any object, m take the null's next is certainly take not to come out

CodePudding user response:

The building Lord, don't use Chinese coding,

CodePudding user response:

reference 1/f, fat to no friend's reply:
with car position is null, then you call last get-together with car position the uninitialized variables, you just declare the variable, the virtual machine to help you create the object is null, not point to any object, take the null's next must be taken not to come out of

And the specific how should solve

CodePudding user response:

Learn to use the debug: : sooner or later master not debug work very hard very sorry later

CodePudding user response:

refer to the second floor guishuanglin response:
the building Lord, don't use Chinese coding,

At ordinary times oneself also need not Chinese, this is something that belongs to group work, and then he used the Chinese encoding

CodePudding user response:

refer to delicate, 4/f, I reply:
o learn to use the debug after morning and evening to master ah not debug work very hard very sorry

Is that the DOS command, is not a good read

CodePudding user response:

refer to 6th floor CHIw_w response:
Quote: refer to delicate, 4/f, I reply:

Learn to use the debug: : sooner or later master not debug after work can be very hard very sorry

Is that the DOS command, is not a good read

Dude you won't download idea or mature Java development tools such as eclipse to use it

CodePudding user response:

Propose the next abnormal debug oneself can solve the problem of eighty percent

CodePudding user response:

refer to 7th floor delicate my response:
Quote: refer to the sixth floor CHIw_w response:

Quote: refer to delicate, 4/f, I reply:

Learn to use the debug: : sooner or later master not debug after work can be very hard very sorry

Is that the DOS command, is not a good read

Dude you won't download idea or use it mature Java development tools such as eclipse

This I use is the eclipse

CodePudding user response:

references 9 f CHIw_w response:
Quote: refer to 7th floor delicate my response:

Quote: refer to the sixth floor CHIw_w response:

Quote: refer to delicate, 4/f, I reply:

Learn to use the debug: : sooner or later master not debug after work can be very hard very sorry

Is that the DOS command, is not a good read

Dude you won't download idea or use it mature Java development tools such as eclipse

I this use is eclipse

Then make a breakpoint and then use the debug mode to perform can see all kinds of the value of a variable

CodePudding user response:

reference CHIw_w reply: 3/f
Quote: refer to 1st floor fat to no friend's reply:

With car position is null, then you call last get-together with car position the uninitialized variables, you just declare the variable, the virtual machine to help you create the object is null, not point to any object, take the null's next must be taken not to come out of

That specific how should solve?
you see your own business, with car position what will be, when you started the first execution with car position should be no, not in accordance with the processing logic how you handle it

CodePudding user response:

Inside the linked list data structure,
Your class has two lists,
Chain store list, actually can bring a header (initialize a header node, do not store any data), in this way, can the building now to avoid the status of the null pointer, if without header, initialized to null, in each of the linked list node list when creating advanced and unconstrained style (null pointer) the judgment of the processing,

CodePudding user response:


Not to come out, and a new bug, license plate number, speaking, reading and writing to return the license plate number is empty, is a problem of team operation

CodePudding user response:

reference CHIw_w reply: 3/f
Quote: refer to 1st floor fat to no friend's reply:

With car position is null, then you call last get-together with car position the uninitialized variables, you just declare the variable, the virtual machine to help you create the object is null, not point to any object, take the null's next must be taken not to come out of

The specific how should solve?


To set up the root, cannot use null

CodePudding user response:

I have a good look at the Java node list, you this queue is the practical application of the node list,

CodePudding user response:

With the vehicle, so the location is null null pointer, the lines of code and the car following position below=p try change the position

CodePudding user response:

The
reference 13 floor CHIw_w reply:

Not to come out, and a new bug, license plate number, speaking, reading and writing to return the license plate number is empty, is a problem of team operating?

At the start of the problem is resolved, now the new problem seems to be in the team, license plate number team success, the team returns an empty what reason be
  • Related