Last active
March 3, 2017 21:24
-
-
Save DevPicon/58911d67b05d25106ca3d7699934ce14 to your computer and use it in GitHub Desktop.
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
| public class Person{ | |
| private String name; | |
| private int age; | |
| public Person(String name, String age){ | |
| this.name = name; | |
| this.age = age; | |
| } | |
| public String getName(){ | |
| return this.name; | |
| } | |
| public int getAge(){ | |
| return this.age; | |
| } | |
| } |
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
| fun ImageView.loadImage(url: String?){ | |
| if(url != null){ | |
| Glide.with(this.context) | |
| .load(url) | |
| .fitCenter() | |
| .into(this) | |
| } | |
| } | |
| myImageView.loadImage(“!insert an url here!”) | |
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
| List people = new ArrayList<Person>(); | |
| people.add(new Person(“Armando”,35)); | |
| people.add(new Person(“Erik”,26)); | |
| people.add(new Person(“Adrian”,30)); | |
| forEach(Person person: people){ | |
| if(person.getName().equals(“Erik”)){ | |
| return person; | |
| } | |
| } |
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
| val people = listOf<Person>(Person("Adrian", 30), Person("Erik",26), Person("Armando", 35)) | |
| val person = people.find { it.name == "Erik" } | |
| println(person) | |
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
| val numberList = listOf(1, 2, 3, 4, 5) | |
| val squared = list.map( i -> i * i) | |
| assertTrue(squared.containsAll(listOf(1,4,9,16,25))) | |
| squared.forEach { println(it) } |
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
| val numberList = listOf(1, 2, 3, 4, 5) | |
| val squared = list.map( i -> i * i) | |
| assertTrue(squared.containsAll(listOf(1,4,9,16,25))) | |
| squared.forEach { println(it) } |
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
| d |
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
| public class MyActivity extends AppCompatActivity{ | |
| @Override | |
| public void onCreate(Bundle saveInstanceState){ | |
| super.onCreate(saveInstanceState); | |
| setContentView(R.layout.main_activity); | |
| TextView myTextView = (TextView) findViewById(R.id.my_textview); | |
| myTextView.setText(“¡Hola Android!”); | |
| } | |
| } |
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
| class MyActivity : AppCompatActivity{ | |
| override fun onCreate(saveInstanceState:Bundle){ | |
| super.onCreate(saveInstanceState); | |
| setContentView(R.layout.main_activity); | |
| my_textview.text = “¡Hola kotlin!” | |
| } | |
| } |
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
| class MyActivity : AppCompatActivity{ | |
| override fun onCreate(saveInstanceState:Bundle){ | |
| super.onCreate(saveInstanceState); | |
| setContentView(R.layout.main_activity); | |
| my_textview.text = “¡Hola kotlin!” | |
| } | |
| } |
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
| class MyActivity : AppCompatActivity{ | |
| override fun onCreate(saveInstanceState:Bundle){ | |
| super.onCreate(saveInstanceState); | |
| setContentView(R.layout.main_activity); | |
| val myTextView = findViewById(R.id.my_textview) as TextView; | |
| myTextView.text = “¡Hola kotlin!”} | |
| } |
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
| var message : String? = null | |
| fun sayHello(message:String?){ | |
| if(message != null){ | |
| println(message) | |
| } | |
| } |
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
| // Clase declarada por en su forma completa | |
| class Persona constructor(name:String, age: Int){ | |
| val name = name | |
| var age = age | |
| } | |
| // Clase simplificada | |
| class Persona(val name: String, var age: Int) | |
| // Data class | |
| data class Persona(val name: String, var age: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment