Giter VIP home page Giter VIP logo

bobbleassessment's Introduction

BigText

Android Assigment for Internship Opportunity at Bobble.ai

Task 1 Android App


Requirements:

  • Android SDK
  • JDK 1.8

Steps to run app:

  1. Connect an android phone or start an android emulator

  2. Make sure USB Debugging is on under Developer Options

  3. Open the BigText android project in Android Studio or Command Line/Terminal

  4. To run using Android Studio, wait for the project to load up and press the green play button on the top right corner and that's it.

  5. To run using the Windows Command Line/Terminal, first install the app by typing this in the project root directory:

    For Windows:

    gradlew installDebug

    For Linux / Mac:

    ./gradlew installDebug
  6. Next, find the app on your device/emulator and open it like you would any other app.

Task 2 Debugging Assigment


The simplest way to recreate a java.util.ConcurrentModificationException is to execute the following code:

import java.util.*;
public class Bobble {

	public static void main(String args[]) {

		//Let's say we have a list of Strings
		List<String> list = new ArrayList<>();

		list.add("Hello");
		list.add("World");
		list.add("Good");
		list.add("Morning");

		// Now while travering the string using the for-each loop,
		for (String s : list) {
			// if we try to remove a value from the list like so,
			list.remove(s);
		}

		// This throws a java.util.ConcurrentModificationException

	}

}

Two ways can be enlisted to avoid it from happening:

  1. Classic for loop
import java.util.*;
public class Bobble {

	public static void main(String args[]) {

		//Let's say we have a list of Strings
		List<String> list = new ArrayList<>();

		list.add("Hello");
		list.add("World");
		list.add("Good");
		list.add("Morning");

		// This does not throw a java.util.ConcurrentModificationException
		for (int i = list.size() - 1; i >= 0; i-- ) {
			String s = list.get(i);
			list.remove(s);
		}

	}

}
  1. Iterator
import java.util.*;
public class Bobble {

	public static void main(String args[]) {

		//Let's say we have a list of Strings
		List<String> list = new ArrayList<>();

		list.add("Hello");
		list.add("World");
		list.add("Good");
		list.add("Morning");

		// This does not throw a java.util.ConcurrentModificationException
		for(Iterator<String> itr = list.iterator(); itr.hasNext();){
			/* String s = itr.next();
			list.remove(s); */ // wrong again
			itr.remove(); // right call
		}

	}

}

bobbleassessment's People

Contributors

shadow-lad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.