I want to make a function with kotlin and java!

Introduction ...

This article was written in 3 previous articles,

** 4th day of article posting every day for 7 days **

It has become

I'll put the code to use below, but see the article three before for the detailed features of this app!

--java version: https://github.com/sato-na/guruwake_java

--kotlin version: https://github.com/sato-na/guruwake_kotlin

↓ This is the main subject of this article ↓

To create a function in each language ...

--For java

Qualifier Return type Function name(argument, argument, …) {
Function content
return Return value
}

Example)

WhoActivity.java


private void addMember() {  //Line 78
    EditText memberET = findViewById(R.id.member_et);
    ListView memberLV = findViewById(R.id.member_lv);
    memberL.add(memberET.getText().toString());
    memberET.getEditableText().clear();
    ArrayList<String> memberLR = (ArrayList<String>) memberL.clone();
    Collections.reverse(memberLR);
    ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, memberLR);
    memberLV.setAdapter(adapter);
    }

--For kotlin

fun function name(argument:Mold, argument:Mold, …) 戻り値のMold {
Function content
return Return value
}

Example)

WhoActivity.kt


fun addMember() {  //Line 52
    memberL.add(member_et.text.toString())
    member_et?.text?.clear()
    var memverLR = ArrayList<String>(memberL)
    memverLR.reverse()
    var adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, memverLR)
    member_lv.adapter = adapter
}

The writing method is very different, but the information required when defining a function is almost the same.

Finally…

This time, I defined the function in java and kotlin. Functions with various functions can be defined depending on the type of argument and the type of return value, so I hope to continue to use them frequently.

I will post an article tomorrow, so please keep an eye on me.

Recommended Posts

I want to make a function with kotlin and java!
I want to transition screens with kotlin and java!
I want to implement various functions with kotlin and java!
I want to return to the previous screen with kotlin and java!
I tried to make a login function in Java
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried to create a shopping site administrator function / screen with Java and Spring
I want to make a button with a line break with link_to [Note]
Let's create a TODO application in Java 2 I want to create a template with Spring Initializr and make a Hello world
I tried to make a group function (bulletin board) with Rails
I tried to make Basic authentication with Java
I did Java to make (a == 1 && a == 2 && a == 3) always true
I want to use java8 forEach with index
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
I tried to break a block with java (1)
I want to display images with REST Controller of Java and Spring!
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (PowerMockito edition)
I want to create a dark web SNS with Jakarta EE 8 with Java 11
I wrote a Lambda function in Java and deployed it with SAM
I want to ForEach an array with a Lambda expression in Java
How to make an app with a plugin mechanism [C # and Java]
Java to play with Function
I want to monitor a specific file with WatchService
I want to define a function in Rails Console
I want to get along with Map [Java beginner]
I used to make nc (netcat) with JAVA normally
I want to add a delete function to the comment function
[Kotlin] I wanted to generate a png with a large capacity per area [Java]
Rails6 I want to make an array of values with a check box
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (black magic edition)
I tried to create a java8 development environment with Chocolatey
I tried to modernize a Java EE application with OpenShift.
How to make a Java container
I want to implement a product information editing function ~ part1 ~
I want to make a specific model of ActiveRecord ReadOnly
I want to call a method and count the number
I just wanted to make a Reactive Property in Java
I tried to interact with Java
I tried to make Java Optional and guard clause coexist
[Ruby] I want to make an array from a character string with the split method. And vice versa.
I tried to make a client of RESAS-API in Java
How to make a Java array
[Java] I want to test standard input & standard output with JUnit
I want to implement it additionally while using kotlin on a site running Java
I want to write a loop that references an index with Java 8's Stream API
Easy to make LINE BOT with Java Servlet Part 2: I tried image messages and templates
I want to return a type different from the input element with Java8 StreamAPI reduce ()
A story that I struggled to challenge a competition professional with Java
I tried to make an Android application with MVC now (Java)
[Java] I tried to make a maze by the digging method ♪
[Java] I want to perform distinct with the key in the object
I want to perform asynchronous processing and periodic execution with Rail !!!
I want to extract between character strings with a regular expression
I want to develop a web application!
How to make a Java calendar Summary
I want to write a nice build.gradle
I want to make an ios.android app
I want to use DBViewer with Eclipse 2018-12! !!
I want to write a unit test!
How to make a Discord bot (Java)
Make a login function with Rails anyway