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
| extern "C" | |
| JNIEXPORT jstring JNICALL | |
| Java_com_example_androidndk_1passing_1complex_1data_NativeLibrary_stringFromJNI(JNIEnv *env, jobject instance) { | |
| std::string hello = "Hello from C++"; | |
| return env->NewStringUTF(hello.c_str()); | |
| } |
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
| /** | |
| * On Get String From JNI Button Clicked Event | |
| * | |
| * @param view | |
| */ | |
| public void onGetStringFromJNIButtonClicked(View view) { | |
| // Define text view to update | |
| TextView textView = findViewById(R.id.textViewGetStringFromJNI); | |
| // Get String From JNI |
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
| String[] emptyArray; // Array which not initialized | |
| int[] myNum = {10, 20, 30, 40}; // This is an integer array | |
| String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; // This is an Array | |
| for (String i : cars) { | |
| System.out.println(i); | |
| } |
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
| for (int i = 0; i < 10; i++) { | |
| System.out.println(i); | |
| } |
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
| int count = 0; | |
| do { | |
| System.out.println(count); | |
| count++; | |
| } | |
| while (count < 10); |
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
| int count = 0; | |
| while (count < 10) { | |
| System.out.println(count); | |
| count++; | |
| } |
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
| int day = 4; | |
| switch (day) { | |
| case 6: | |
| System.out.println("Today is Saturday"); | |
| break; | |
| case 7: | |
| System.out.println("Today is Sunday"); | |
| break; | |
| default: | |
| System.out.println("Weekday"); |
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
| int time = 200; | |
| String res = (time < 100) ? "Less Than 100." : "Grater Than 100."; | |
| System.out.println(res); |
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
| int time = 200; | |
| if (time < 100) { | |
| System.out.println("Less Than 100."); | |
| } else if (time < 150) { | |
| System.out.println("Between 100 - 150."); | |
| } else { | |
| System.out.println("Greater Than 150."); | |
| } | |
| // Outputs "Greater Than 150." |
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
| if (200 > 100) { | |
| System.out.println("200 is greater than 100"); | |
| } |