This file contains 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
// Declare stack, push two strings | |
final Stack<String> strings = new Stack<String>(); | |
final String test1 = "Test!"; | |
final String test2 = "Test again!"; | |
strings.push(test1); | |
strings.push(test2); | |
// Pop second string off | |
final String pop = strings.pop(); | |
assertSame(test2, pop); |
This file contains 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.learnandroid.listviewtutorial.adapter; | |
import java.util.ArrayList; | |
import java.util.GregorianCalendar; | |
import java.util.List; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.widget.ListView; |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Layout for individual news entries in a list --> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent"> | |
<!-- Icon shown next to the title/subtitle --> | |
<ImageView | |
android:id="@+id/news_entry_icon" |
This file contains 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.learnandroid.listviewtutorial.adapter; | |
import java.text.DateFormat; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.ImageView; |
This file contains 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.learnandroid.listviewtutorial.adapter; | |
import java.util.Date; | |
/** | |
* Encapsulates information about a news entry | |
*/ | |
public final class NewsEntry { | |
private final String title; |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/hello" /> |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/hello" /> |
This file contains 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.learnandroid.listviewtutorial.adapter; | |
import android.app.Activity; | |
import android.os.Bundle; | |
public class MainActivity extends Activity { | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |
This file contains 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
def sumOfMultiples( base, maximum ): | |
a = maximum / base | |
b = (a * (a+1)) / 2 | |
return (b * base) | |
if __name__ == "__main__": | |
threes = sumOfMultiples( 3, 999 ) | |
fives = sumOfMultiples( 5, 999 ) | |
fifteens = sumOfMultiples( 15, 999 ) | |
This file contains 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 sum = 0; | |
for(int i = 0; i < 1000; i++) { | |
if( (i % 3) == 0 || (i % 5) == 0 ) { | |
sum += i; | |
} | |
} | |
printf("Sum is: %d\n", sum); | |
return 0; |