массив стеков

Я решил свои собственные проблемы.

1) app.config ['MySQL_HOST'] = 'localhost' -> MySQL необходимо заменить на 'MYSQL'

  1. return redirect (url_for ('index')) - > Индекс необходимо заменить на «регистр»

простые орфографические ошибки ...

5
задан guerda 8 May 2009 в 06:47
поделиться

6 ответов

Stack<Card>[] decks = new Stack[9];       // Declare
Card c = decks[5].pop();                  // This compiles - java 'knows' the type
Integer i = decks[4].pop();               // This will not compile
2
ответ дан 18 December 2019 в 13:19
поделиться

Joshua Bloch does an excellent job of describing this problem in Effective Java, Second Edition. Check out the relevant section on Google Book Search.

The advice he offers is to prefer lists to arrays. Your code might then look something like:

List<Stack<Card>> cards = new ArrayList<Stack<Card>>();
9
ответ дан 18 December 2019 в 13:19
поделиться

You can do the following, though this gives you a compiler "unchecked" warning.

Stack<Card>[] cards = (Stack<Card>[]) new Stack[52];
2
ответ дан 18 December 2019 в 13:19
поделиться

Why do you use arrays anyway ?

It is a low level programming structure.

Using List or Set instead (eg org.apache.commons.collections.list.LazyList) if you don't want to bother with innitialization.

Or at least

Arrays.asList(new Stack[52]) to wrap an array into a list.

I couldnt reproduce jour error anywany .. :( perchaps it's because a different warning/errorlevel set.

1
ответ дан 18 December 2019 в 13:19
поделиться

Well, the array does not need to be a generic because he is always defined as this. Why do you think you have to cast? I think that eclipse is somewhat confused here.

0
ответ дан 18 December 2019 в 13:19
поделиться

It's to do with type erasure. Basically the generic types only exist at compile time and have no presence at run time

Have at look at this forum post for a better explanation.

0
ответ дан 18 December 2019 в 13:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: