Developers Journal http://developersjournal.in Journal for Developers Tue, 19 Sep 2017 11:43:19 +0000 en-US hourly 1 https://wordpress.org/?v=4.8.2 http://developersjournal.in/wp-content/uploads/2017/05/cropped-dj-circular-1-1-100x100.png Developers Journal http://developersjournal.in 32 32 How to declare Gradle Repositories http://developersjournal.in/declare-gradle-repositories/ http://developersjournal.in/declare-gradle-repositories/#respond Tue, 19 Sep 2017 11:43:19 +0000 http://developersjournal.in/?p=2167 Looking for using external files and dependencies in the Gradle project. Repositories block can help you out in that.

The post How to declare Gradle Repositories appeared first on Developers Journal.

]]>
When you are developing projects using Gradle and you are not sure how to implement external dependencies to your project, then this journal entry can help you with that. Lets take some examples on understanding how to declare Gradle repositories for external dependencies. But before we start, we have to understand that the project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.

Declare Gradle Repositories

Gradle find the external dependencies files by looking into in a repository block defined in the build.gradle file. A repository is basically a collection of files, organized by groupname, and version. Gradle understands several different repository formats, such as Maven and Ivy. It also has several different ways of accessing the repository, such as using the local file system or HTTP.

By default, Gradle does not define any repositories of its own. You have to define at least one before accessing any external dependencies. One of the most common options is to use the Maven central repository:

build.gradle


repositories {
    mavenCentral()
}

Or we can use JCenter:

build.gradle


repositories {
    jcenter()
}

Gradle also gives you the option to use your own Maven or Ivy repositories server.

build.gradle


// Maven Repositories Server
repositories {
    maven {
        url "http://repo.yourcompany.com/maven2"
    }
}


// IVY Repositories Directory
repositories {
    ivy {
        url "http://repo.yourcompany.com/repo"
    }
}

You can also have repositories on the local file system. This works for both Maven and Ivy repositories.

build.gradle


repositories {
    ivy {
        // URL can refer to a local directory
        url "../local-repo-folder"
    }
}

Sometimes a repository will have the POMs published to one location, and the JARs and other artifacts published at another location. To define such a repository, you can do:

build.gradle


repositories {
    maven {

        // Look for POMs and artifacts, such as JARs, here
        url "http://repo2.yourcompany.com/maven2"
        
        // Look for artifacts here if not found at the above location
        artifactUrls "http://repo.yourcompany.com/jars"
        artifactUrls "http://repo.yourcompany.com/jars2"

    }
}

 

To access the protected maven repository servers, you need to have basic authentication and have to specify the username and password to be used when you define the repository:

build.gradle


repositories {
    maven {
        credentials {
            username 'user'
            password 'password'
        }
        url "http://repo.yourcompany.com/maven2"
    }
}

 

If you like this journal entry and want some more entries like these then please stay tuned and connected by subscribing to our newsletter or you can join us on our social platforms – facebooktwittergoogle+.

 

The post How to declare Gradle Repositories appeared first on Developers Journal.

]]>
http://developersjournal.in/declare-gradle-repositories/feed/ 0
How to Build Java Project using Gradle http://developersjournal.in/build-java-project-using-gradle/ http://developersjournal.in/build-java-project-using-gradle/#respond Tue, 19 Sep 2017 07:01:17 +0000 http://developersjournal.in/?p=2162 Gradle is an open source build automation system that replaces XML based build scripts with an internal DSL that is based on Groovy programming language.

The post How to Build Java Project using Gradle appeared first on Developers Journal.

]]>
Gradle is an open source build automation system that replaces XML based build scripts with an internal DSL that is based on Groovy programming language. In this journal entry, we will be journeying on “How to Build Java Project using Gradle”.

Simple Java Project using Gradle

#1: Setup the Java Project

The very first step is to create the project folder where we will be working on creating this project. For simplicity sake let’s keep a very simple name of the folder “getting-started-gradle”.

$ mkdir getting-started-gradle

Once the project folder is created, let’s move into that folder and create the java project structure inside that.

// *nix System
$ mkdir -p src/main/java/hello

Within this directory, we can create our java classes and we can make as many classes as we want. But for this example, we will be creating only two classes namely "HelloWorld.java" and "GreetMessage.java"

src/main/java/hello/HelloWorld.java

package hello;

public class HelloWorld {
  public static void main(String[] args) {
    GreetMessage greetMessage = new GreetMessage();
    System.out.println(greetMessage.displayMessage());
  }
}

src/main/java/hello/GreetMessage.java

package hello;

public class GreetMessage {
  public String displayMessage() {
    return "Hello world!";
  }
}

#2: Install Gradle

Now that you have a project that you can build with Gradle, you can install Gradle.

It’s highly recommended to use an installer:

As a last resort, if neither of these tools suit your needs, you can download the binaries from http://www.gradle.org/downloads. Only the binaries are required, so look for the link to gradle-version-bin.zip. (You can also choose gradle-version-all.zip to get the sources and documentation as well as the binaries.)

Unzip the file to your computer, and add the bin folder to your path.

To test the Gradle installation, run Gradle from the command-line:

$ gradle

If all goes well you will see the output as:

:help

Welcome to Gradle 1.10.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

BUILD SUCCESSFUL

Total time: 5.446 secs

The above output confirms that the Gradle has been installed on your machine. Now let’s find out what Gradle can do for us before we even create the famous build.gradle file.

Run the following command on the terminal to see the list of gradle tasks that are available.

$ gradle tasks

The output of the above command should look like this:

:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------

init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------

dependencies - Displays all dependencies declared in root project 'java'.
dependencyInsight - Displays the insight into a specific dependency in root project 'java'.
help - Displays a help message
projects - Displays the sub-projects of root project 'java'.
properties - Displays the properties of root project 'java'.
tasks - Displays the tasks runnable from root project 'java'.

To see all tasks and more detail, run with --all.

BUILD SUCCESSFUL

Total time: 4.119 secs

 

The list of tasks will grow as you add plugins to build.gradle, so you’ll occasionally want to run tasks again to see what tasks are available.

Speaking of adding plugins, next you add a plugin that enables basic Java build functionality.

#3: Build Java code

Starting simple, create a very basic build.gradle file in the <project folder> you created at the beginning of this guide. Give it just one line:

apply plugin: 'java'

The above specified single line in the build configuration brings a significant amount of power. Run the gradle task command again, and you see new tasks added to the list, including tasks for building the project, creating JavaDoc, and running tests.

You’ll use the gradle build task frequently. This task compiles, tests, and assembles the code into a JAR file. You can run it like this:

$ gradle build

After a few seconds, “BUILD SUCCESSFUL” indicates that the build has completed.

To see the results of the build effort, take a look in the build folder. Therein you’ll find several directories, including these three notable folders:

  • classes. The project’s compiled .class files.
  • reports. Reports produced by the build (such as test reports).
  • libs. Assembled project libraries (usually JAR and/or WAR files).

The classes folder has .class files that are generated from compiling the Java code. Specifically, you should find HelloWorld.class and Greeter.class.

At this point, the project doesn’t have any library dependencies, so there’s nothing in the dependency_cache folder.

The reports folder should contain a report of running unit tests on the project. Because the project doesn’t yet have any unit tests, that report will be uninteresting.

The libs folder should contain a JAR file that is named after the project’s folder. Further down, you’ll see how you can specify the name of the JAR and its version.

#4: Declare dependencies

The simple Hello World sample is completely self-contained and does not depend on any additional libraries. Most applications, however, depend on external libraries to handle common and/or complex functionality.

For example, suppose that in addition to saying “Hello World!”, you want the application to print the current date and time. You could use the date and time facilities in the native Java libraries, but you can make things more interesting by using the Joda Time libraries.

First, change HelloWorld.java to look like this:

package hello;

import org.joda.time.LocalTime;

public class HelloWorld {
  public static void main(String[] args) {
    LocalTime currentTime = new LocalTime();
    System.out.println("The current local time is: " + currentTime);

    GreetMessage greetMessage = new GreetMessage();
    System.out.println(greetMessage.displayMessage());
  }
}

Here HelloWorld uses Joda Time’s LocalTime class to get and print the current time.

If you ran gradle build to build the project now, the build would fail because you have not declared Joda Time as a compile dependency in the build.

For starters, you need to add a source for 3rd party libraries.

repositories {
    mavenCentral()
}

The repositories block indicates that the build should resolve its dependencies from the Maven Central repository. Gradle leans heavily on many conventions and facilities established by the Maven build tool, including the option of using Maven Central as a source of library dependencies.

Now that we’re ready for 3rd party libraries, let’s declare some.

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile "joda-time:joda-time:2.2"
    testCompile "junit:junit:4.12"
}

With the dependencies block, you declare a single dependency for Joda Time. Specifically, you’re asking for (reading right to left) version 2.2 of the joda-time library, in the joda-time group.

Another thing to note about this dependency is that it is a compile dependency, indicating that it should be available during compile-time (and if you were building a WAR file, included in the /WEB-INF/libs folder of the WAR). Other notable types of dependencies include:

  • providedCompile. Required dependencies for compiling the project code, but that will be provided at runtime by a container running the code (for example, the Java Servlet API).
  • testCompile. Dependencies used for compiling and running tests, but not required for building or running the project’s runtime code.

To wrap things up for this guide, here is the completed build.gradle file:

build.gradle

apply plugin: 'java'

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile "joda-time:joda-time:2.2"
    testCompile "junit:junit:4.12"
}

 

In the next journal entry, we will be looking at the use of Gradle Wrapper to build and run our java application. So stay tuned and connected by subscribing to our newsletter or you can join us on our social platforms – facebook, twitter, google+.

The post How to Build Java Project using Gradle appeared first on Developers Journal.

]]>
http://developersjournal.in/build-java-project-using-gradle/feed/ 0
Best Programming Languages for Data Mining http://developersjournal.in/best-programming-languages-data-mining/ http://developersjournal.in/best-programming-languages-data-mining/#respond Thu, 14 Sep 2017 07:28:24 +0000 http://developersjournal.in/?p=2156 Data mining is the process of discovering predictive information from the analysis of large databases. Here are the best programming languages to help you with data mining.

The post Best Programming Languages for Data Mining appeared first on Developers Journal.

]]>
The process of converting raw data into some valuable info is basically termed as Data Mining. To know more about the clienteles and progress more effective marketing/advertising strategies the industries are now using specified softwares. Data mining depends on the computer processing and an assortment of data. The tools used for data mining forecast the future drift plus behavior. They also permit business to reach the knowledge driven choice. Let’s have a look at some of the best programming languages for data mining.

DJ Recommended Reads: 
Top 12 Interesting Careers To Explore in Big Data

Best Programming Languages for Data Mining

R Project “R”

R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. The R language was first revealed in 1993 as per their WIKI page.

R is the most widespread language in data science. With just a few lines of code, you could generate sleek graphics toward representing the figures. Normally, excel files are used by data analyst; however, now R is gradually being used for fiscal modeling mainly as a visualization tool.

One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. At its essential, R offers imposing tools for data mining plus analysis.

 

Python“Python”

Programmers regard Python as a clear and simple language with a high readability. The simplicity exists both in the language itself as well as in the encouragement to write clear and simple code prevalent among Python programmers. Python has firm data mining abilities and has appeared as a decent option in data processing. Python is the finest tool for medium scale documents processing.

Python is extensive and flexible, so persons easily connect to it. We all distinguish Python as an interpreted language, we might think that it is slow, however, some astonishing work has been done above the past years toward improving Python’s performance. The point here is that, if you want high-performance calculations, Python is a feasible finest option today. Python is fast gaining majority and becoming a more concrete language. Python is instinctive and easier to learn than R, and its ecology has grown intensively in recent years for freelance services, creating it more accomplished of the statistical analysis beforehand reserved for R.

These are two most successful programming languages for data mining widely used by the programmers and data analysts. There are other programming languages also which are used for data mining and some of them are mentioned below:

  • Java
  • Hadoop and Hive
  • Kafka and Storm
  • Julia

Do let us know if we need to include any language that we have missed here in the list but you as developers are using in your data mining projects.

The post Best Programming Languages for Data Mining appeared first on Developers Journal.

]]>
http://developersjournal.in/best-programming-languages-data-mining/feed/ 0
15 Best Productivity Apps for Android Devices http://developersjournal.in/15-best-productivity-apps-for-android-devices/ http://developersjournal.in/15-best-productivity-apps-for-android-devices/#respond Wed, 13 Sep 2017 09:05:00 +0000 http://developersjournal.in/?p=2131 The reason we are getting more productive every day is because of the existence of smartphones. They’re like tiny super computers that are very handy to carry and we keep them in our pocket.

The post 15 Best Productivity Apps for Android Devices appeared first on Developers Journal.

]]>
The reason we are getting more productive every day is because of the existence of smartphones. They’re like tiny super computers that are very handy to carry and we keep them in our pocket. They help us connect to the web world, let us do work, and we always keep them with us. These features and more like that makes them prime candidates to help us be more productive. There are a ton of options for apps that can help you be more productive in your life. Let’s have a look at the 15 best productivity apps for Android!

15 Best Productivity Apps

App #1: To Do List

Android To Do List

What is SplenDO? – SplenDO is smart task list for everyday use. It is truly usable with great user experience.
No matter who you are and what you do – you will be better organized! At home, at work and in your free time – you will focus on really important things! SplenDO is powerful in its simplicity and convenience of use.

KEY FEATURES:

  • User friendly task management
  • Grouping tasks in handy task lists
  • Smart home screen widgets show instantly what to do
  • Intelligent notifications exactly when you need them
  • Syncing with Google that just works

MORE DETAILS

  • Adding tasks via voice
  • Notifications use sounds, vibrations and built-in speech synthesizer (TTS)
  • Icon widget – icon with optional today’s and overdue tasks counter
  • List Widget – resizable widget displays upcoming tasks
  • Status bar – component (in the notifications area) keeping you up to date
  • Quick Task Bar – to add something hot quickly
  • Support for recurring tasks
  • Time for shopping? Need to add many tasks at one go? Great, batch mode is on-board!
  • Support for tasks without a due date, all-day-long tasks and tasks at a specific hour of the day
  • Bidirectional synchronization with Google Tasks
  • Many useful configuration options
  • Predefined task lists
  • Actions on group of tasks (bulk actions, long-click selection support)
  • Integration with sharing on Android – sharing tasks with other apps and receiving shared data
  • Creating tasks from the content of system clipboard
  • SplenDO is free to download and use
  • Splend Apps support and more!

App #2: Business Calendar 2

Android Business Calendar 2

Business Calendar 2 is free and offers you a lot of features in its basic version. Additionally, you can get even more user-friendly features by upgrading directly from within the app. Users of the old Business Calendar Pro can access the pro features of Business Calendar 2 for free as long as the old app is installed.

KEY FEATURES:

  • Event planner and task management
  • Month, week and day view
  • Agenda with live search
  • Year view
  • Uses Android calendar sync which allows synchronization e.g. with Google Calendar and Exchange
  • Support for local calendars and tasks
  • Holidays calendar
  • Birthdays of your contacts
  • Voice input option
  • Advanced event reminders
  • Month, week, day, agenda, icon and tasks widget

App #3: Evernote

Android Evernote

Evernote gives you the tools you need to keep your work effortlessly organized:

  • Write, collect and capture ideas as searchable notes, notebooks, checklists and to-do lists
  • Take notes in a variety of formats, including: text, sketches, photos, audio, video, PDFs, web clippings and more.
  • Use camera capture to easily scan and comment on pieces of paper, including printed documents, business cards, handwriting and sketches.
  • Attach Microsoft Office docs, PDFs and photos.
  • Organize your receipts, bills and invoices.
  • Use Evernote as a digital notepad and easy-to-format word processor for all your thoughts as they come

App #4: DropBox

Android DropBox

Dropbox keeps your files and your team in sync. Anything you save in Dropbox can be easily accessed from all of your devices. Sending large files is easy, even to people who don’t have a Dropbox account. And with features like the doc scanner, shared folders, offline access, and more, collaborating with others is simple.

FEATURES:

  • Work on files with others through shared folders.
  • Use the document scanner to turn receipts, whiteboards, and notes into PDFs.
  • Comment on files to share feedback with your team.
  • Sync, share, and edit Word, Excel, and Powerpoint files

App #5: Trello

Android Trello

Trello gives you a perspective on all your projects, at work and at home.

Whether it’s managing a team, writing an epic screenplay, or just making a grocery list, Trello is your sidekick for getting things done and staying organized.

With Trello you can:

  • Create boards to organize anything you’re working on.
  • Use them solo or invite coworkers, friends, and family to collaborate.
  • Customize workflows for different projects
  • Add checklists of “To-Dos” on cards
  • Assign tasks to yourself and coworkers
  • Comment on items with your friends
  • Attach files from Google Drive and Dropbox
  • Upload photos and videos
  • Reply to comments from Android Wear
  • Display cards in a calendar view with the Calendar Power-Up
  • Work offline and boards will sync automatically when reconnected

Trello is free to use forever.

App #6: Slack

Android Slack

Slack brings team communication and collaboration into one place so you can get more work done, whether you belong to a large enterprise or a small business. Check off your to-do list and move your projects forward by bringing the right people, conversations, tools, and information you need together. Slack is available on any device, so you can find and access your team and your work, whether you’re at your desk or on the go.

Use Slack to: 

  • Communicate with your team and organize your conversations by topics, projects, or anything else that matters to your work.
  • Message or call any person or group within your team.
  • Share and edit documents and collaborate with the right people all in Slack.
  • Integrate into your workflow, the tools and services you already use including Google Drive, Salesforce, Dropbox, Asana, Twitter, Zendesk, and more.
  • Easily search a central knowledge base that automatically indexes and archives your team’s past conversations and files.
  • Customize your notifications so you stay focused on what matters

App #7: Google Keep

Android Google Keep

Capture inspiration when it strikes! Keep is simply the quickest way to offload ideas, thoughts, and to-dos without losing focus.

  • Create notes and lists, set time and place reminders, and check off your completed tasks.
  • Add a collaborator to your notes and lists, then get things done together.
  • Add photos and drawings, or just draw on your photos.
  • Dictate your thoughts, Keep will transcribe them for you.
  • Search notes by automagically created topics.
  • Group notes together with #labels.
  • Color notes for easy scanability.
  • Access your notes on any device. synced automatically to your phone, tablet, watch, and laptop via the Google Keep website, or Chrome app.
  • Use “Ok Google” voice commands to “take a note” or “add to to-do list”.

App #8: Microsoft Apps

Android Microsoft Apps

Microsoft Apps, provides an easy way to browse all of Microsoft’s Android offerings across categories like Productivity, Education, Entertainment, Communication, and News. You can also discover apps that you never knew existed, as well as brand new additions to the Microsoft family.

FEATURES:

  • Browse all the apps from Microsoft on Android in one simple experience
  • See what apps you already have installed; find new and popular downloads
  • Browse by category

App #9: Wunderlist: To-Do List & Tasks

Android Wunderlist

Wunderlist helps millions of people around the world capture their ideas, things to do and places to see. Whether you’re sharing a grocery list with a loved one, working on a project, or planning a vacation, Wunderlist makes it easy to share your lists and collaborate with everyone in your life. Wunderlist instantly syncs between your phone, tablet and computer, so you can access your lists from anywhere.

KEY FEATURES:

  • Create all the lists you need and access them from your phone, tablet and computer.
  • Easily share lists and collaborate with family, friends and colleagues.
  • Start conversations about your to-dos.
  • Attach photos, PDFs, presentations and more.
  • Share the work and delegate to-dos.
  • Setting a Reminder ensures you never forget important deadlines (or birthday gifts) ever again.
  • Organize your projects for home, work and everywhere in between with Folders

Wunderlist is free to download and use. Wunderlist Pro upgrades your experience and gives you unlimited access to Files, Assigning and Subtasks to help you accomplish even more for $4.99 a month through an in-app purchase.

App #10: Microsoft Office Mobile

Android Microsoft Office Mobile

Microsoft Office Mobile is the Office companion for phones running Android OS prior to v4.4. You can access, view and edit your Word, Excel and PowerPoint documents from virtually anywhere. Documents look like the originals, thanks to support for charts, animations, SmartArt graphics, and shapes. When you make quick edits or add comments to a document, the formatting and content remain intact.*

KEY FEATURES:

Access documents from virtually anywhere:

  • Cloud – With your phone, you can access Office documents that are stored on OneDrive, OneDrive for Business, or SharePoint.
  • Recent Documents – Office Mobile is cloud-connected. The documents you’ve recently viewed on your computer are readily available on your phone in the recent documents panel.
  • Email Attachments – You can view and edit Office documents attached to email messages.*

App #11: Reddit

Android Reddit

Get all the freshest content on the Internet in Reddit’s official mobile app! Discover top trending topics, breaking news, viral video clips, funny jokes and hot memes.

Get the Best of What Really Interests You 
Create your own feed by subscribing to your favorite subreddits, to get the socially curated, constantly updated feed of news headlines, fun stories, pics, memes, and videos that interest YOU. Alternatively, find out what’s trending on r/popular.

On Reddit, you can be yourself, with your Reddit profile and persona disconnected from your real-world identity. Because we don’t want your mom to know you’re into r/knitting.

Contribute & Share Your Stuff 
Upload photos, post memes, contribute stories, join discussions, and help other users find the best links, videos, pics and news by upvoting and downvoting posts.

App #12: PushBullet – SMS on PC

Android PushBullet

Stay Connected

  • Conveniently send and receive SMS messages from your computer.
  • Reply to messages from many popular apps including WhatsApp, Kik, and Facebook Messenger.
  • Easily share links and files between your devices, or with friends

Never Miss A Notification

  • See all of your phone’s notifications on your computer, including phone calls.
  • Dismiss a notification on your computer and it goes away on your phone too.
  • Use Pushbullet Channels to subscribe to timely notifications about things you care about

Save Time

  • Text from your computer using your keyboard instead of grabbing your phone
  • The easiest way to get a link or file onto your phone to open or share
  • Deal with notifications on your computer as they arrive

App #13: Goal Tracker & Habit List

Android Goal Tracker

Do you want to change habits? Track goals? Accomplish new year’s resolutions?
Goal Tracker & Habit Streak will help you by keeping track of your progress.

Why use Goal Tracker & Habit List:

  • All free. No ads, no in-app purchases.
  • Easy to use.
  • Daily, weekly, monthly, yearly habits/goals.
  • Schedule weekly habits/goals for any combination of week days.
  • Notifications. You don’t forget to take action.
  • Widgets (only Android 4.0 and later). Your habits/goals are at your fingertips.
  • Export to Google Drive, Dropbox, and/or local storage (/storage/sdcard/Goal Tracker Habit Streak). You never lose your habits/goals.
  • Daily auto backup to local storage. Use the calendar to select any day in last week and restore habits/goals if needed.
  • Weekly progress calendar view. Log all habits/goals on one screen.
  • Monthly calendar view. Log all days on one screen.
  • Google Play backups.Your habits/goals should be transferred to your new devices (depends on your settings).

App #14: Wrike

Android Wrike

Wrike is a powerful cloud software tool for project management, planning, and team collaboration. Trust an app used by thousands of companies — including small, mid-size and enterprise Fortune 500 companies. Wrike was included as one of the fastest growing companies in North America on Deloitte’s Technology Fast 500™ List for the second consecutive year.

KEY PROJECT MANAGEMENT & COLLABORATION FEATURES:

  • Access your Wrike Account: Free, Professional, Business, Enterprise or Wrike for Marketers plans, or create a new account from your phone.
  • Quickly access folders and projects.
  • Assign and schedule tasks.
  • Review Inbox, notifications, @ mentions, and Activity Stream when you’re on the go.
  • Attach existing images and files to tasks right from your phone.
  • View & adjust projects in List, Board, Timeline^ or Workload^ views.
  • Track time spent on tasks our quick automated timer^.
  • Receive or submit requests through customized forms*.
  • Access your personal and shared Dashboards^

With comprehensive project management tools, Wrike is perfect for all your project scheduling needs.

App #15: Creativity

Android Creativity

Creativity is the ability to generate new ideas or concepts, or new associations between ideas and known concepts, which usually produce original solutions.

With this application, you can use various tools and techniques to originate and develop new ideas in a creative way.

Choose the technique that more you can help your goal from the following that is included in the app:

  • Brainstorming: It generates a lot of ideas about a topic and then chooses the most appropriate. There is also the option to evaluate those ideas.
  • Six Thinking Hats: To tackle a problem from various perspectives: objective, emotional, positive, negative, creative, and control.
  • Exquisite Corpse: Continue the word or phrase that someone else has started in order to create an intuitive and spontaneous composition.
  • Write text: Use this tool to type any text you can think of.
  • Random words: To obtain new words from other words or random characters.
  • Forced relationship: Find the link between several words with apparently nothing in common at the same time help to solve a problem.
  • Attributes and improvements: To break down a product or process into its components or steps and develop ways to improve each of these parts.
  • Questions and Answers: Get the solution to the problem by the doubts that arise.
  • Transformation: From the initial and final steps insert all intermediate stages to achieve the objective.
  • SCAMPER: Mainly used to improve a product, service or existing process, helps focus our creative capacity covering several points.

Combine several techniques to solve a larger problem by dividing it into parts or merge the results of other techniques to use them together. You have a description of each technique and how to use them with the help of this application. Share ideas and files with other people so that they provide other solutions. Basic version of Creativity Pro, with certain limitations.

 

 

 

 

 

 

 

 

 

The post 15 Best Productivity Apps for Android Devices appeared first on Developers Journal.

]]>
http://developersjournal.in/15-best-productivity-apps-for-android-devices/feed/ 0
Rules for Java Coding Convention and Clean Code http://developersjournal.in/rules-java-coding-convention-clean-code/ http://developersjournal.in/rules-java-coding-convention-clean-code/#respond Mon, 11 Sep 2017 18:31:31 +0000 http://developersjournal.in/?p=2053 Best practices and recommendations of the Java developers community gained from the past years of language use.

The post Rules for Java Coding Convention and Clean Code appeared first on Developers Journal.

]]>
This journal entry consolidates the best practices and recommendations of the Java developers community gained from the past years of language use.

Java Coding Convention – Rules

clean code

Rule #1

a) Don’t use the wildcard character in package import statement. Always use the qualified name of the package with the import statement.

Example:


import java.io.* //Wrong Statement

import java.io.file //Correct Statement

b) Import statement should be alphabetically sorted, separated in groups with a blank line.

.static import
.java, .javax, then org and com packages
.others imports

Example:


import static java.lang.Math.min;

import java.io.File;
import java.io.FileReader;

import javax.servlet.GenericServlet;

import org.springframework.context.ApplicationContext;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import backtype.storm.tuple.values;

Rule #2

One class per file. The name of the file must be the same as the class name.

Rule #3

Avoid deep Nesting: Too many levels of nesting makes the code harder to read and follow.

Rule #4

Class names should be nouns unless you have a good reason for it not to be a noun. First letter of the class name should be in capital letter.

Example:


class DevelopersJournal {

// Code goes here....

}

Rule #5

Name of the methods using verb-object pair, such as readJsonFile()

Rule #6

Methods or functions returning a boolean type should generally start with a verb is, or alternatives that fit better in   some situations like has/have, can or should, etc.

Example:


isValid(); or isOpen();

Rule #7

a) Variables should be named so that they make it clear what it contains. Variable names should always be easy-to-read, be short yet meaningful, mixed case with a lowercase first letter English words.

b) Use plural names for arrays/collections of objects.

c) Constant (static final) variable names should be in all capital letters and separate words in the name with the underscore, i.e., PRIORITY_NORMAL

Java Clean Code – Rules

Rule #1

Keep your piece of code where it belongs. Classes should be placed in the proper package name and methods to their appropriate classes.

Rule #2

Methods should follow the principle of Keep It Short and Simple (KISS). Functions should have a single responsibility, i.e., a function should do one thing. Avoid using boolean arguments because they cause confusion. Boolean (flag) arguments loudly declare that the function does more than one thing.

Rule #3

Avoid OS dependent behavior, e.g., Unix-centric constants “\n”, “/”, etc.

Rule #4

Explicitly declare all field types as private and provide a public get and set method to read and write properties. This restricts the direct access to properties and fields and using get and set you can validate your data.

Rule #5

Declare a local variable as close as possible to its first use.

Rule #6

You should document all of your methods even the private ones if they are complex.

Rule #7

Every class created should be inside a package where it belongs.

Rule #8

Private class variables should have underscore suffix. Underscore nicely resolves the problem of finding reasonable variable names for setter and getter methods.

Example:


private String _name;

void setName(String name) {

this._name = name;

}

Rule #9

The term compute can be used in methods where something is computed. Example:valueSet.computeAverage();

Rule #10

Array specifiers must be attached to the type not the variable.

Example:


int arrayInt[] = new int[10]; // Wrong

int[] arrayInt = new int[10]; // Right

Summary

By following the above-specified Rules for coding conventions and clean code, the developers like you and me can simplify our life. These not only help in writing an error free code but it also helps in better understanding once we try to come back to our code after a long time of writing.

The post Rules for Java Coding Convention and Clean Code appeared first on Developers Journal.

]]>
http://developersjournal.in/rules-java-coding-convention-clean-code/feed/ 0
Understanding Java Scanner – Text Parsing http://developersjournal.in/understanding-java-scanner-text-parsing/ http://developersjournal.in/understanding-java-scanner-text-parsing/#respond Mon, 11 Sep 2017 12:53:19 +0000 http://developersjournal.in/?p=2120 Java's Scanner class makes parsing text trivial. We can use this class in a good number of ways, which we will be scanning into this journal entry.

The post Understanding Java Scanner – Text Parsing appeared first on Developers Journal.

]]>
Java provides a Scanner class that can be used as a text parser. This class can parse primitive types and strings using regular expressions.

A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types. Let us dig deep dive into some of the usage scenarios of the Scanner class.

Java Scanner: Read a Whole File

To read the whole file in a single String, use the following. The delimiter here is the regular expression for the beginning of the file.

try (Scanner scanner = new Scanner(new File(filename));) {
    scanner.useDelimiter("\\A");
    String all = scanner.next();
}

 

[ DJ Recommends: How to Concatenate Strings in Java 8 ]

Read Text by Paragraph

Specifying an empty-line regex as the delimiter allows you to read text by paragraphs. The regular expression pattern specifies the multi-line flag, so use ^ and $ match at the beginning and end of each line, rather than the whole input.

try (Scanner scanner = new Scanner(new File(filename));) {
    scanner.useDelimiter("(?m:^$)");
    int ntoken = 0;
    while (scanner.hasNext()) {
    String token = scanner.next();
    ntoken++;
    System.out.printf("%3d) %s%n", ntoken, token);
    }
}

Count Words in a File

The default delimiter used by the Scanner is whitespace. It returns text tokens separated by whitespace. Let us use this fact to count the words in a file. The following code prints the value as well as its index from the file. Note that the Scanner implements the AutoCloseable interface so we can use it in try-with-resources block.

try (Scanner scanner = new Scanner(new File(filename));) {
    int nword = 0;
    while (scanner.hasNext()) {
    String sent = scanner.next();
    nword++;
    System.out.printf("%3d) %s%n", nword, sent);
    }
}

 

[ DJ Recommends: Best Practices For Java Exception Handling ]

Conclusion

Java’s Scanner class makes parsing text trivial. By setting the proper delimiter, we can accomplish various parsing tasks easily.

The post Understanding Java Scanner – Text Parsing appeared first on Developers Journal.

]]>
http://developersjournal.in/understanding-java-scanner-text-parsing/feed/ 0
Connect MySQL Using Nodejs App http://developersjournal.in/connect-mysql-using-nodejs-app/ http://developersjournal.in/connect-mysql-using-nodejs-app/#respond Sun, 10 Sep 2017 09:37:36 +0000 http://developersjournal.in/?p=2102 MongoDB is the very first choice when working with the database using Nodejs but we can connect to other databases also. Here we will be looking to connect MySql using Nodejs app.

The post Connect MySQL Using Nodejs App appeared first on Developers Journal.

]]>
MongoDB is the very first choice when working with database using Nodejs but we can connect to other databases also. Here we will be looking to connect MySql using Nodejs app.

Connect MySql Using Nodejs App

Let’s start by creating a new nodejs project by following these simple steps

Using NPM

Step 1. Create a working project directory where we will create the Nodejs project.


$ mkdir connect_mysql_nodejs

$ cd connect_mysql_nodejs

Step 2. Once inside the project folder lets initiate the npm command to create the project template and setup the package.json file.


$ npm init

// filing up the procedure
name: (connect_mysql_nodejs) //default folder name
version: (1.0.0) 0.0.1 // your version number
description: Tutorial on Nodejs With Mysql Queries
entry point: (index.js) app.js // your main file
test command:
git repository: // git project if any
keywords: nodejs mysql
author: developersjournal
license: (ISC)

The above commands will create the package.json file for us. The final file looks like this:

MySql Package.JSON file

Step 3. Now we need to install the MySql dependency in the project so that we can start using it.


$ npm install mysql --save

The --save parameter will save the contents of the MySql dependencies file locally on the project folder under node_modules.

Sql Database Connection

Step 4. Import the MySql package in the app.js file using the require method and also start the mysql localhost server where we will be establishing the connection.

NOTE: We will be working on app.js file as this is the file which we have declared while creating the project.


var mysql = require('mysql');
// Creating the connection
var con = mysql.createConnection({
host: "localhost", //Hostname where MySql is running
user: "username", //Username to connect to MySql
password: "password" //Password for MySql User
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!"); // message
});

Now to run the app.js file simply write the command


$ node app.js

Connected! //Successfully Connected to MySql

Database And Table Creation

Now we will be having a look at how to create the database as well a table in that particular Database. But first, we will create the database.


var mysql = require('mysql');

var con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword"
});

con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("CREATE DATABASE mydb", function (err, result) {
if (err) throw err;
console.log("Database created");
});
});

This will connect database as well as creates the database of name mydb. So run the file as we run earlier i.e $ node app.js.

Creating Table

Creating table is as similar as it was creating a database, but all we need to do is to give the database name in the ‘con’ variable. let’s see:


var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "yourusername",
password: "yourpassword",
database: "mydb" // Declare the database name
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
// Create table Query
var sql = "CREATE TABLE customers (id VARCHAR(12), name VARCHAR(30))";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Table created");
});
});

Inserting And Viewing Data

Let us see the further procedure for inserting data and viewing in the terminal. So first we have to insert data into the table.


var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "mydb"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sql = "INSERT INTO customers (id, name) VALUES (0001, 'Mr. Developer')";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});

After the data is inserted successfully, now we can display the data of table on the terminal. So just add the SELECT Query to get the data.


con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("SELECT * FROM customers", function (err, result) {
if (err) throw err;
console.log(result);
});
});

And the data which is displayed are in raw (json format).


$ node app.js

Connected!
[ RowDataPacket { id: '1', name: 'Mr. Developer' }]

Updating And Deleting Data

For Editing the table you just need to change the query. so first we will update the table


var mysql = require('mysql');

var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "mydb"
});
con.connect(function(err) {
if (err) throw err;
var sql = "UPDATE customers SET name = 'Mr. Journal' WHERE id = 0001";
con.query(sql, function (err, result) {
if (err) throw err;
console.log(result.affectedRows + " record(s) updated"); // Shows the number of updated table
});
});

And at last for deleting the record or table from the database and that is similar to all above queries.


con.connect(function(err) {
if (err) throw err;
var sql = "DELETE FROM customers WHERE id = 0001";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Number of records deleted: " + result.affectedRows);
});
});

Conclusion

 

The post Connect MySQL Using Nodejs App appeared first on Developers Journal.

]]>
http://developersjournal.in/connect-mysql-using-nodejs-app/feed/ 0
Tips for Android Developers for Successfully Publishing App on Google Play Store http://developersjournal.in/tips-for-android-developers-to-succeed-in-google-play-store/ http://developersjournal.in/tips-for-android-developers-to-succeed-in-google-play-store/#respond Fri, 08 Sep 2017 06:54:21 +0000 http://developersjournal.in/?p=2085 Tips for Android Developers for successfully publishing app on Google Play Store.

The post Tips for Android Developers for Successfully Publishing App on Google Play Store appeared first on Developers Journal.

]]>
Tips for Android Developers for successfully publishing app on Google Play Store.

Successfully publishing an app on Google Play Store is not just about submitting the finished code and then sitting back and watching the downloads as well as dollars flowing in.

There are several steps to be taken before the final app development stage and the very first download. As you celebrate your app’s launch into the market, you might ignore some of most very important aspects that lay the foundation of your app’s success.

In order to make sure that all basics are covered, there’s a definitive checklist of things to do before launching an app on Google Play Store. By following these steps, you’ll see how easy it is to create a successful app.

Publish app Google Play Store

Steps for Successfully Publishing App

01: Test the app

Testing is one of the most important processes when launching an app. Make sure to test the app thoroughly before finally submitting it to the Google Play Store. Android is an open platform that has both pros and cons. Since there is an extreme fragmentation of Android devices, it often gets really difficult for app developers to ensure consistency with respect to user experience, which is very important.

Instead of testing an app on a single device for iOS, it is very important to test the Android app and check the same across an array of canvas sizes, form factors, and models. As per Open Signal Maps analysis, there are more than 4000 different types of Android devices. In addition, there are two crucial variables for testing – Android OS version and screen size. So testing the app for both would be wise.

02: OS version and screen size

Testing on various Android devices implies that you need to consider different versions of Android OS and screen sizes too. Ideally, Android developers should test the app with devices that come with both higher, as well as lower resolutions, so that the app works seamlessly for both. It is very important to cater to both classes.

As far as the OS version is concerned, developers should aim to make the app compatible with some of the lower versions; you can gradually add more features for the higher versions. Working with native features for each version can make the process really easier.

You have to define the devices you want to discover the app in the Google Play Store. This can enable you to restrict the reach of your app to specific Android devices, as mentioned.

Meanwhile, Android already has its architecture that sup- ports scaling up and down; the technology is called Density Independent Pixels. Nonetheless, some developers may not be happy with the result. Remember, bad performance means unhappy users, which is bad news for business.

03: Setting up a Google Checkout account

If you want to sell a paid Android app or game and make money via in-app advertising, you have to set up a Google Checkout Merchant Account. However, only a few countries are included in the list. Therefore, you have to make sure you are allowed to sell a paid app on Google.

If you want your app to be free, Google Play Store would not permit you to upgrade the app if you (at one point) decide that you want to go from free to paid. Therefore, you have to come up with a long-term monetizing plan and strategy from the very beginning.

04: Make your app presentable

Once you are ready to submit the app to the Google Play Store, you have to once again check the app design and overall aesthetics. It is very important to make sure the app looks attractive enough and the design is really trendy. You should also create an appealing icon for the app, a clearly-written app description, screenshots of the app and gather some attractive videos to draw the users’ attention towards the general appearance of your app. Remember, this is a crucial step for the app’s success, especially since the first impression does count.

05: Marketing strategy for your app

You should plan the launch of your Android app well. Make it stylish and eye-catching. A press release would also be great. You can also invite relevant individuals to cover your app launch. You must contact some of the top app review websites and request them to write genuine reviews. In addition, you must visit forums, groups, app bloggers and social networks, and speak about the app. The power of social media is far-reaching when it comes to app promotion. You can even promote the app on various online Android app discovery platforms. This can get you ratings and reviews.

06: Keep options open for user support

Make sure you have open offers for user support, which is very important. You have to set up a system in such a way that you can respond to queries immediately and start interacting with users. This is a very good way to resolve issues quickly. You can also have a FAQ section in which you can answer the common queries and set up support email and chat for additional help. Likewise, you should try to enable multiple payment options for users.

07: App performance tracking

Your job is not done the moment you put an app on Play Store; this is just the beginning. To make sure your app is successful, you have to keep track of its performance to know exactly how well the app is doing in real time marketplace. Pay attention to users’ feedback and improvise your marketing strategy, as well as the app’s presentation.

There are two key in-app analytics tools – Flurry and Google Mobile App Analytics. Whereas the former is designed to monitor users’ impression of the app, the latter is meant to give you details of app download, rating, and reviews. Both tools are really effective in tracking your app’s performance.

Concluding Note

Although the above-mentioned steps do not guarantee the success of an app, this comprehensive list can help you build a successful app. It can give you a chance to make sure the app succeeds.

Source Viva: http://www.freewebtutorials.info/best-tips-android-developers-succeed-google-play-store/

The post Tips for Android Developers for Successfully Publishing App on Google Play Store appeared first on Developers Journal.

]]>
http://developersjournal.in/tips-for-android-developers-to-succeed-in-google-play-store/feed/ 0
6 Mobile App Testing Mistakes Developers Should Avoid http://developersjournal.in/6-mobile-app-testing-mistakes-developers-avoid/ http://developersjournal.in/6-mobile-app-testing-mistakes-developers-avoid/#respond Fri, 08 Sep 2017 06:37:55 +0000 http://developersjournal.in/?p=2091 The success or failure of a mobile app depends on its testing. It is as vital as developing an application. If you launch an app while rushing the testing stage, it can be a huge failure in the app market. The failure of an app can be related to any of the following reasons: If […]

The post 6 Mobile App Testing Mistakes Developers Should Avoid appeared first on Developers Journal.

]]>
The success or failure of a mobile app depends on its testing. It is as vital as developing an application. If you launch an app while rushing the testing stage, it can be a huge failure in the app market. The failure of an app can be related to any of the following reasons:

  • If your app has any form of errors
  • App isn’t user friendly

Therefore, if you want to improve the marketability and boost app downloads, app testing is most critical for your app.

Taking the shortcut method to test an app is not surprising as many developers tends to finish developing the app on time. This is where they fail to identify many loopholes in the app, which may completely ruin the application in future. It is important to understand that testing a mobile app is not child’s play. To achieve the desired result, the testing stage involves several rounds of iteration to test all the features and functionalities.

Here are 6 common mistakes that developers tend to do as they perform the critical process of mobile app testing. Try avoiding these mistakes to make the phase smoother and ensure highest standards of quality result.

DJ Recommended Reads: Getting Started with Android Testing

UI/UX given more emphasis than functionalities

App testers often tend to forget about the features provided by the applications to deliver the best user experience to end users. Design, Looks, and User Experience does matter, but what about the usability perspective? Why would users download your app if it does not fulfill it’s sole purpose or the features are not working properly? A good app is all about delivering what users get from it and not only what they see in it. Therefore, app testers should follow a more balanced approach when it comes to test UI/UX as well as the features or usability of the app.

Testing an app without an in-depth knowledge of it

This is one of the biggest mistakes that most app testers do. They have the responsibility of testing an app that they have never heard of. And they tend to quickly test some of its features, UI and UX and submit the report. This is not the ideal situation for mobile app testers. The tester should have in-depth knowledge of the app – its functional requirements, features, and business logic. This way a tester will cover all functionalities and user flows in the app, and make sure it performs optimally and as per core business requirements.

Trying to test everything

It is impossible to test a mobile app against every device, location, Operating System or network. However, it is vital to have objective visibility of what you are testing and how well it can target the customers who would use your app. Google Analytics and backend logs can help to create a clear picture of customer behavior.

Suppose if you are handling 50 test cases and you have to test on 10 different devices on 5 different network environments, there are innumerable executions you have to make. But that is impossible. However, what you can do is to study market demands and user behavior to identify what are your most important devices, test cases, and networks, and prioritize testing them.

DJ Recommended Reads: Getting Started with Android Testing

You are testing a mobile app like a web

The world of website development is slow and static, and the concept does not apply to the highly dynamic and evolving mobile world. In web development, testing on only a few browsers is enough. However, if you do so for mobile apps, you would cover roughly 15% of the market. Staggering, right? There is more. Mobile applications need to be updated every month. On the contrary, a web browser updates every year; so, you are fine web testing in the same environment. But if you do that in mobile, you would be testing for an old device after only a few months. Therefore, taking the web approach for mobile app testing is wrong.

Improper Crash Logs

Nothing annoys a user more than frequent app crashes, and this can be devastating for the success of your app. Crashes are normal until the time your application is completely free of bugs and errors. Therefore, it is vital to maintain proper logs for all the crashes taking place in the testing phase and prepare a report highlighting what crashes to resolve. This is also where in-depth knowledge of the app tester is important. Unless he knows what the crash is all about, he will be unable to prioritize it and send an accurate report to the developers.

Discrepancy in reporting

For successful app testing, finding bugs and maintaining crash logs is as important as sending accurate reports. Unfortunately, due to lack of knowledge, time constraints and other factors, app testers fail to send the reports correctly and commit mistakes. These discrepancies put the developers in a dilemma as to what areas to resolve and what needs to be given more priority. Due to mistakes in reporting and miscommunication, the bugs or errors in the app cannot be resolved correctly and the app hits the market with its flaws. This can be devastating for the app when users find errors or bugs in it.

DJ Recommended Reads: Getting Started with Android Testing

Conclusion

The objective of testing a mobile app is to deliver a quality product at the end of the day. Therefore, it is important for the testers to avoid common mistakes at every stage of testing and send appropriate & insightful reports that can help the developers to fix the issues and deliver a bug-free app

 

The post 6 Mobile App Testing Mistakes Developers Should Avoid appeared first on Developers Journal.

]]>
http://developersjournal.in/6-mobile-app-testing-mistakes-developers-avoid/feed/ 0
What is the Difference between HashMap and HashTable? http://developersjournal.in/difference-between-hashmap-and-hashtable/ http://developersjournal.in/difference-between-hashmap-and-hashtable/#respond Thu, 07 Sep 2017 12:32:44 +0000 http://developersjournal.in/?p=2064 One of the frequently asked interview question for Java/J2EE professionals is "What is the Difference between HashMap and HashTable?"

The post What is the Difference between HashMap and HashTable? appeared first on Developers Journal.

]]>
One of the frequently asked interview question for Java/J2EE professionals is “What is the Difference between HashMap and HashTable?”. In this journal, we will digging deep into understanding the major differences between a HashMap and HashTable.

DJ Recommended Reads:

HashMap vs HashTable

HashMapHashTable
HashMap is non-synchronized. This means if it’s used in a multithread environment then more than one thread can access and process the HashMap simultaneously.Hashtable is synchronized. It ensures that no more than one thread can access the Hashtable at a given moment of time. The thread which works on Hashtable acquires a lock on it to make the other threads wait till its work gets completed.
HashMap allows one null key and any number of null values.Hashtable doesn’t allow null keys and null values.
HashMap implementation LinkedHashMap maintains the insertion order and TreeMap sorts the mappings based on the ascending order of keys.Hashtable doesn’t guarantee any kind of order. It doesn’t maintain the mappings in any particular order.
Initially Hashtable was not the part of collection framework it has been made a collection framework member later after being retrofitted to implement the Map interface.HashMap implements Map interface and is a part of collection framework since the beginning.

Another difference between these classes is that the Iterator of the HashMap is a fail-fast and it throws ConcurrentModificationException if any other Thread modifies the map structurally by adding or removing any element except iterator’s own remove() method. In Simple words fail-fast means: When calling iterator.next(), if any modification has been made between the moment the iterator was created and the moment next() is called, a ConcurrentModificationException is immediately thrown.

Enumerator for the Hashtable is not fail-fast.

For e.g.

HashMap:

HashMap hm= new HashMap();
....
....
Set keys = hm.keySet();
for (Object key : keys) {
    //it will throw the ConcurrentModificationException here
    hm.put(object & value pair here); 
}

HashTable:

Hashtable ht= new Hashtable();
....
.....
Enumeration keys = ht.keys();
 for (Enumeration en = ht.elements() ; en.hasMoreElements() ; en.nextElement()) {
      //No exception would be thrown here
      ht.put(key & value pair here); 
 }

DJ Recommended Reads:

When to use HashMap and Hashtable?

As stated above the main difference between HashMap & Hashtable is synchronization. If there is a need for thread-safe operation then HashTable can be used as all its methods are synchronized but it’s a legacy class and should be avoided as there is nothing about it, which cannot be done by HashMap. For the multi-threaded environment, we would recommend you to use ConcurrentHashMap (almost similar to Hashtable) or even you can make the HashMap synchronized explicitly.

Synchronized operation gives the poor performance so it should be avoided until unless required. Hence for a non-thread environment, HashMap should be used without any doubt.

The post What is the Difference between HashMap and HashTable? appeared first on Developers Journal.

]]>
http://developersjournal.in/difference-between-hashmap-and-hashtable/feed/ 0