Skip to main content
guest
Join
|
Help
|
Sign In
Creando-metodos-en-JAVA
Home
guest
|
Join
|
Help
|
Sign In
Creando-metodos-en-JAVA
Wiki Home
Recent Changes
Pages and Files
Members
Favorites
20
All Pages
20
Acceso a un metodo
Ejemplos de Metodos
Objetos y metodos
Perimetro y area de un rectangulo
Programa en Java
Que es un metodo
Sentencia RETURN
Add
Add "All Pages"
Done
Sentencia RETURN
Edit
0
1
…
0
Tags
No tags
Notify
RSS
Backlinks
Source
Print
Export (PDF)
return
La palabra reservada return nos permite hacer que un metodo retorne un valor o que simplemete termine intempestivamente en algun punto del codigo
por ejemplo tenemos el siguiete metodo de la clase FunMat
class FunMat{
Lee lee;
Msg msg=new Msg();
Arreglos arr;
double aproxima(double dat, int nDec){
double y, aux;
aux=Math.pow(10, nDec);
y=((int)(dat*aux+.5)/aux);
return y;
}
double rand(int limMen, int limMay, int nEnt, int nDec){
double rand;
boolean aux=false;
nEnt=(int)(Math.pow(10, (double)(nEnt)));
do{
rand=Math.random()*nEnt;
if(rand<limMay&&rand>limMen){
aux=false;
}
else aux=true;
}while(aux);
return aproxima(rand, nDec);
}
int[] frecuencia(double vec[], int limMen, int limMay){
int cont[]=new int[limMay];
int aux=0;
for(int i=0; i<cont.length;i++){
cont[i]=0;
for(int j=0; j<vec.length;j++){
if((int)(vec[j])==i) aux++;
}
cont[i]=aux;
aux=0;
}
return cont;
}
}
Javascript Required
You need to enable Javascript in your browser to edit pages.
help on how to format text
Turn off "Getting Started"
Home
...
Loading...
La palabra reservada return nos permite hacer que un metodo retorne un valor o que simplemete termine intempestivamente en algun punto del codigo
por ejemplo tenemos el siguiete metodo de la clase FunMat
class FunMat{
Lee lee;
Msg msg=new Msg();
Arreglos arr;
double aproxima(double dat, int nDec){
double y, aux;
aux=Math.pow(10, nDec);
y=((int)(dat*aux+.5)/aux);
return y;
}
double rand(int limMen, int limMay, int nEnt, int nDec){
double rand;
boolean aux=false;
nEnt=(int)(Math.pow(10, (double)(nEnt)));
do{
rand=Math.random()*nEnt;
if(rand<limMay&&rand>limMen){
aux=false;
}
else aux=true;
}while(aux);
return aproxima(rand, nDec);
}
int[] frecuencia(double vec[], int limMen, int limMay){
int cont[]=new int[limMay];
int aux=0;
for(int i=0; i<cont.length;i++){
cont[i]=0;
for(int j=0; j<vec.length;j++){
if((int)(vec[j])==i) aux++;
}
cont[i]=aux;
aux=0;
}
return cont;
}
}