Return;

1 resposta
C
Estou estudando uma aplicação, e encontrei um return; Sendo q conheço o return para retornar alguma variável ;ex. num método.
Public String exemplo(){
String texto = vou retornar;
return texto;
}
Ai me deparei com um return; puro vou postar o exemplo do método. Sendo q queria saber como é usado esse return no exemplo abaixo só preciso saber do return o q ele ta retornando pq ele é usado dentro de um catch se alguém souber pode ajudar fico grato.
private void handleFileOpenCompleed(fileOperationEvent event) {
		
		isFileNeedOpen = false;
		if (event.getStatus() != OperationEvent.EVT_SUCCESS) {
			Debug.debug("fileServiceControl open pub TRAN MODE_CREATE");
		} else {
			Debug.debug("fileServiceControl openCompleted EVT_SUCCESS");
			try {
				int filesize = file.getSize();
				Debug.debug("file.getSize()[" + filesize + "]");
				file.seek(filesize, true);
				Debug.debug("file.seek()[" + file.seek(filesize, true) + "]");
				if (state == OperState.STATE_FILE_WRITELEN) {
					int write_length = Integer.parseInt(inputInteger);
					String write_buffer = "";
					for (int i = 1; i <= write_length; i++) {
						write_buffer = write_buffer + (i % 10);
					}
					Debug.debug("UI writeString " + write_length);
					file.writeString(write_buffer);
					// file.writeString("1234567890123456789012345678901234567890123456789012345");
				} else {
					if (trans_type == TYPE_PURCHASE) {
						Debug.debug("UI writeString ");
						file.writeString(contentToFile); // save
					} else {
						
						Debug.debug("UI writeString ");
						file.writeString(contentToFile);
					}
				}
			} catch (AccessException e) {
				Debug.debug("file.writeString error![" + e.getMessage() + "]");
				return;
			}
		}
	}

1 Resposta

danieldestro

Se o método é void, a diretiva return simplesmente aborta a execução do método.

Exemplo:

public void teste( int a ) { if( a < 10 ) { //fim return; } System.out.println("A é maior ou igual a DEZ"); }

Criado 9 de julho de 2006
Ultima resposta 9 de jul. de 2006
Respostas 1
Participantes 2