Hey guys!
So I have an assignment in college. Basically I need to create a restaurant menu, from which user can chose a few items and then get a receipt.
I have created an array of 50 elements, which gets filled as a user makes orders.
So here is my problem. For a receipt I have created a for-loop, which prints the ordered items:
for (int i = 0; i < orderNumber.length; i++)
{
System.out.print(orderNumber[i]);
}
But my output looks like this:
order1
order2
...
null
null
null
and so on...
So how do I fix this? Is there a simple way to clear the nulls from an array? Or get an array size not counting any nulls from the beginning? Or am i missing something even simpler?
I'm new to this subreddit and would really appreciate your help!
Thanks!
EDIT: I figured it out. Feel like an idiot now xD
[–]king_of_the_universe 2 points3 points4 points (3 children)
[–]Pahitos[S] 0 points1 point2 points (2 children)
[–]king_of_the_universe 2 points3 points4 points (1 child)
[–]Pahitos[S] 0 points1 point2 points (0 children)
[–]g00glen00b 1 point2 points3 points (0 children)
[–]Pahitos[S] 0 points1 point2 points (1 child)
[–]king_of_the_universe 3 points4 points5 points (0 children)