This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.ejemplos; | |
import java.time.LocalDate; | |
import java.util.Comparator; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class EjemploOrdenarLista { | |
public static void main(String[] args) { | |
List<Person> personsList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
import java.util.function.Function; | |
public class FunctionSample { | |
public static void main(String[] args) { | |
String r1 = run(StringUpper::upper, "Hola a todos"); | |
System.out.println(r1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class StringPalindrome { | |
public static String go(String s) { | |
StringBuilder r = new StringBuilder(); | |
for (char c : s.toCharArray()) { | |
r.insert(0, c); | |
} | |
return r.toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class StringUpper { | |
public static String upper(String s) { | |
return s.toUpperCase(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
import java.util.function.Supplier; | |
public class SupplierSample { | |
public static void main(String[] args) { | |
StringHello s1 = new StringHello(); | |
System.out.println(run(s1::getHello)); //tiene un resultaado |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class StringUpperHello { | |
public String hiUpper() { | |
return "HOLA A TODOS"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class StringHello { | |
public String getHello() { | |
return "Hola"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
import java.util.function.Consumer; | |
public class ConsumerSample { | |
public static void main(String[] args) { | |
NumberPrint np = new NumberPrint(); | |
run(np::print); //un método de un objeto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class NumberSquared { | |
public void showNumber(int a) { | |
System.out.println("El cuadrado del parámetro es: " + (a * a)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apuntesdejava.methods.param.example; | |
public class NumberPrint { | |
public void print(int number) { | |
System.out.printf("El valor del parámetro es %d\n", number); | |
} | |
} |