public String[] decode(String message)
{
String ans1 = "hey";
String ans2 = "hi";
return {ans1 , ans2}; // Is it correct?
}
Questo esempio precedente non funziona correttamente. Sto ottenendo un erroreCome restituire due stringhe in una dichiarazione di reso?
Come posso ottenere la domanda iniziale?
Perché è così? Ive alderly ha creato una stringa .. se creo una nuova stringa come ans1 = new String [] funzionerà? – higherDefender
@ D.J. perché anche se hai creato oggetti String non hai ancora creato un array String (vedi la mia risposta modificata per maggiori dettagli) –