Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int getColorForName(String name) {
        if (name.isEmpty()) {
            return 0xFF202020;
        }
        int colors[] = { 0xFFe91e63, 0xFF9c27b0, 0xFF673ab7, 0xFF3f51b5, 0xFF5677fc, 0xFF03a9f4, 0xFF00bcd4,
                0xFF009688, 0xFFff5722, 0xFF795548, 0xFF607d8b };
        return colors[(int) ((name.hashCode() & 0xffffffffl) % colors.length)];
    }
}