Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Identical if statements behaving in different ways

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Identical if statements behaving in different ways

    I'm writing a program which takes the title of a model car and breaks the elements down into HTML metadata.

    All of the car companies (Ford, etc.) are in an array, which is called upon to be assigned to a variable only if the model title contains that word, Ford, for example.

    Here is the code:

    private static boolean keepRunning;
     
    public static void main (String[] args) {
     
        do {
        GenerateData(); }
        while (keepRunning = true);
        if (keepRunning = false) {
            System.exit(0);
        }
    }
     
        public static void GenerateData() {
     
        Scanner sc = new Scanner(System.in);
        String title = null;
        String abstr = "Shop for diecast model cars at [SITE REMOVED]";
        String scale = null;
        String diecastManu = null;
        String metaModel = null;
        String metaMake = null;
        String defaultstring = "quality";
     
        String[] metaMakesList = {"Abarth", "Acura", "Ahrens", "Alfa Romeo"
                +"Alpine Renault", "AMC", "American LaFrance", "Aprilia", "Aston Martin" 
                +"Audi", "Austin", "Austin-Healey", "Bedford", "Benelli", "Bentley", "BMW"
                +"Buffalo", "Bugatti", "Buick","Cadillac","Caterham", "Chaparrel"
                + "Checker","Chevrolet","Chrysler","Citroen", "Cleveland", "Cord","DAF"
                + "Daimler","Dakota","Datsun","Dauer","De Soto", "Delahaye", "DeLorean", "Dennis", "Divco"
                + "Dodge", "Duesenberg", "Edsel", "F1", "Ferrari","Fiat","Ford","Freightliner"
                +"GAZ", "GMC", "Gumpert", "Halo", "Helicopter","Hello Kitty", "Honda","Horch","Hudson"
                + "Hummer","Hyundai","Infiniti", "International", "Jaguar", "Jeep", "K2", "Kaiser"
                + "Koenigsegg","Lamborghini","Lancia","Land Rover", "LandRover", "Lexus","Leyland"
                + "Lincoln", "Lotus","Mack","Magirus-Deutz","Maserati","Maxim", "Maybach"
                + "Mazda","McLaren","Mercedes-Benz","Mercedes Benz","Mercedes","Mercury","Messerschmitt"
                +"Meyers Manxter","MG","Mini","Mini Cooper","Mitsubishi","Morgan","Morris"
                + "Nash", "Nissan","Oldsmobile","Opel","Packard","Pagani","Panhard","Panoz","Pantera"
                + "Peugeot","Pierce-Arrow","Plymouth","Pontiac","Porsche","Puegoet","Renault","Reo"
                + "Rolls Royce", "Rolls-Royce","Saturn","Scion","Seagrave","Seat","Simca", "Smart"
                + "Studebaker","Stutz", "Subaru","Tata","Toyota","Triumph","Tucker","TVR","TX1"
                + "VolksWagen","Volvo","White","Willys"};
     
        String[] scaleList = {"1:12","1:18","1:24","1:32","1:43","1:64","1/12", "1/18", "1/24", "1/32", "1/43", "1/64"};
     
        String[] diecastManuList = {"Muscle Machines","Jada Toys"
                        +"AUTOart","Kinsmart","M2","1BaddRide"
                        +"Greenlight","Anson","Arko","Auto World"
                        +"Bauer","BBR","BBurago","Carney Plastics"
                        +"Collectable Diecast","CMC","Double Horse"
                        +"Elvis Motor Classics","Classic Metal Works"
                        +"Ertl","Fast Women","First Gear","GMP","Hawk"
                        +"Highway 61","Hot Wheels","Hot Works","IXO"
                        +"Johnny Lightning","Kustom City","Kyosho"
                        +"LandMice","Lane Exact Detail","Liberty Classics"
                        +"LJP","Luxury","Lindberg","Maisto","Minichamps"
                        +"Mira-Solido","MJX","Mondo Motors","Motor City"
                        +"Motorhead","Motormax","New Ray","Norev"
                        +"Paragon","Paudi","Pioneer","Phoenix Mint"
                        +"Precision Miniatures","Revell","Ricko Ricko"
                        +"RMZ City","Road Mice","Saico","Schuco","Shelby Collectibles"
                        +"Signature","So Real Concepts","SpecCast"
                        +"SunStar","Superior","Syma","True Scale"
                        +"Unique Replicas","Universal Hobbies"
                        +"Vitesse","XQ","Yat-Ming","Welly"};
     
        //System.out.println(diecastManuList.length);
        System.out.println("Please paste model title.");
        title = sc.nextLine();
     
        if (title.toLowerCase().contains(metaMakesList[0].toLowerCase()))
        { metaMake = metaMakesList[0];}
        else if (title.toLowerCase().contains(metaMakesList[1].toLowerCase()))
        { metaMake = metaMakesList[1];}
        else if (title.toLowerCase().contains(metaMakesList[2].toLowerCase()))
        { metaMake = metaMakesList[2];}
        else if (title.toLowerCase().contains(metaMakesList[3].toLowerCase()))
        { metaMake = metaMakesList[3];}
        else if (title.toLowerCase().contains(metaMakesList[4].toLowerCase()))
        { metaMake = metaMakesList[4];}
        else if (title.toLowerCase().contains(metaMakesList[5].toLowerCase()))
        { metaMake = metaMakesList[5];}
        else if (title.toLowerCase().contains(metaMakesList[6].toLowerCase()))
        { metaMake = metaMakesList[6];}
        else if (title.toLowerCase().contains(metaMakesList[7].toLowerCase()))
        { metaMake = metaMakesList[7];}
        else if (title.toLowerCase().contains(metaMakesList[8].toLowerCase()))
        { metaMake = metaMakesList[8];}
        else if (title.toLowerCase().contains(metaMakesList[9].toLowerCase()))
        { metaMake = metaMakesList[9];}
        else if (title.toLowerCase().contains(metaMakesList[10].toLowerCase()))
        { metaMake = metaMakesList[10];}
        else if (title.toLowerCase().contains(metaMakesList[11].toLowerCase()))
        { metaMake = metaMakesList[11];}
        else if (title.toLowerCase().contains(metaMakesList[12].toLowerCase()))
        { metaMake = metaMakesList[12];}
        else if (title.toLowerCase().contains(metaMakesList[13].toLowerCase()))
        { metaMake = metaMakesList[13];}
        else if (title.toLowerCase().contains(metaMakesList[14].toLowerCase()))
        { metaMake = metaMakesList[14];}
        else if (title.toLowerCase().contains(metaMakesList[15].toLowerCase()))
        { metaMake = metaMakesList[15];}
        else if (title.toLowerCase().contains(metaMakesList[16].toLowerCase()))
        { metaMake = metaMakesList[16];}
        else if (title.toLowerCase().contains(metaMakesList[17].toLowerCase()))
        { metaMake = metaMakesList[17];}
        else if (title.toLowerCase().contains(metaMakesList[18].toLowerCase()))
        { metaMake = metaMakesList[18];}
        else if (title.toLowerCase().contains(metaMakesList[19].toLowerCase()))
        { metaMake = metaMakesList[19];}
        else if (title.toLowerCase().contains(metaMakesList[20].toLowerCase()))
        { metaMake = metaMakesList[20];}
        else if (title.toLowerCase().contains(metaMakesList[21].toLowerCase()))
        { metaMake = metaMakesList[21];}
        else if (title.toLowerCase().contains(metaMakesList[22].toLowerCase()))
        { metaMake = metaMakesList[22];}
        else if (title.toLowerCase().contains(metaMakesList[23].toLowerCase()))
        { metaMake = metaMakesList[23];}
        else if (title.toLowerCase().contains(metaMakesList[24].toLowerCase()))
        { metaMake = metaMakesList[24];}
        else if (title.toLowerCase().contains(metaMakesList[25].toLowerCase()))
        { metaMake = metaMakesList[25];}
        else if (title.toLowerCase().contains(metaMakesList[26].toLowerCase()))
        { metaMake = metaMakesList[26];}
        else if (title.toLowerCase().contains(metaMakesList[27].toLowerCase()))
        { metaMake = metaMakesList[27];}
        else if (title.toLowerCase().contains(metaMakesList[28].toLowerCase()))
        { metaMake = metaMakesList[28];}
        else if (title.toLowerCase().contains(metaMakesList[29].toLowerCase()))
        { metaMake = metaMakesList[29];}
        else if (title.toLowerCase().contains(metaMakesList[30].toLowerCase()))
        { metaMake = metaMakesList[30];}
        else if (title.toLowerCase().contains(metaMakesList[31].toLowerCase()))
        { metaMake = metaMakesList[31];}
        else if (title.toLowerCase().contains(metaMakesList[32].toLowerCase()))
        { metaMake = metaMakesList[32];}
        else if (title.toLowerCase().contains(metaMakesList[33].toLowerCase()))
        { metaMake = metaMakesList[33];}
        else if (title.toLowerCase().contains(metaMakesList[34].toLowerCase()))
        { metaMake = metaMakesList[34];}
        else if (title.toLowerCase().contains(metaMakesList[35].toLowerCase()))
        { metaMake = metaMakesList[35];}
        else if (title.toLowerCase().contains(metaMakesList[36].toLowerCase()))
        { metaMake = metaMakesList[36];}
        else if (title.toLowerCase().contains(metaMakesList[37].toLowerCase()))
        { metaMake = metaMakesList[37];}
        else if (title.toLowerCase().contains(metaMakesList[38].toLowerCase()))
        { metaMake = metaMakesList[38];}
        else if (title.toLowerCase().contains(metaMakesList[39].toLowerCase()))
        { metaMake = metaMakesList[39];}
        else if (title.toLowerCase().contains(metaMakesList[40].toLowerCase()))
        { metaMake = metaMakesList[40];}
        else if (title.toLowerCase().contains(metaMakesList[41].toLowerCase()))
        { metaMake = metaMakesList[41];}
        else if (title.toLowerCase().contains(metaMakesList[42].toLowerCase()))
        { metaMake = metaMakesList[42];}
        else if (title.toLowerCase().contains(metaMakesList[43].toLowerCase()))
        { metaMake = metaMakesList[43];}
        else if (title.toLowerCase().contains(metaMakesList[44].toLowerCase()))
        { metaMake = metaMakesList[44];}
        else if (title.toLowerCase().contains(metaMakesList[45].toLowerCase()))
        { metaMake = metaMakesList[45];}
        else if (title.toLowerCase().contains(metaMakesList[46].toLowerCase()))
        { metaMake = metaMakesList[46];}
        else if (title.toLowerCase().contains(metaMakesList[47].toLowerCase()))
        { metaMake = metaMakesList[47];}
        else if (title.toLowerCase().contains(metaMakesList[48].toLowerCase()))
        { metaMake = metaMakesList[48];}
        else if (title.toLowerCase().contains(metaMakesList[49].toLowerCase()))
        { metaMake = metaMakesList[49];}
        else if (title.toLowerCase().contains(metaMakesList[50].toLowerCase()))
        { metaMake = metaMakesList[50];}
        else if (title.toLowerCase().contains(metaMakesList[51].toLowerCase()))
        { metaMake = metaMakesList[51];}
        else if (title.toLowerCase().contains(metaMakesList[52].toLowerCase()))
        { metaMake = metaMakesList[52];}
        else if (title.toLowerCase().contains(metaMakesList[53].toLowerCase()))
        { metaMake = metaMakesList[53];}
        else if (title.toLowerCase().contains(metaMakesList[54].toLowerCase()))
        { metaMake = metaMakesList[54];}
        else if (title.toLowerCase().contains(metaMakesList[55].toLowerCase()))
        { metaMake = metaMakesList[55];}
        else if (title.toLowerCase().contains(metaMakesList[56].toLowerCase()))
        { metaMake = metaMakesList[56];}
        else if (title.toLowerCase().contains(metaMakesList[57].toLowerCase()))
        { metaMake = metaMakesList[57];}
        else if (title.toLowerCase().contains(metaMakesList[58].toLowerCase()))
        { metaMake = metaMakesList[58];}
        else if (title.toLowerCase().contains(metaMakesList[59].toLowerCase()))
        { metaMake = metaMakesList[59];}
        else if (title.toLowerCase().contains(metaMakesList[60].toLowerCase()))
        { metaMake = metaMakesList[60];}
        else if (title.toLowerCase().contains(metaMakesList[61].toLowerCase()))
        { metaMake = metaMakesList[61];}
        else if (title.toLowerCase().contains(metaMakesList[62].toLowerCase()))
        { metaMake = metaMakesList[62];}
        else if (title.toLowerCase().contains(metaMakesList[63].toLowerCase()))
        { metaMake = metaMakesList[63];}
        else if (title.toLowerCase().contains(metaMakesList[64].toLowerCase()))
        { metaMake = metaMakesList[64];}
        else if (title.toLowerCase().contains(metaMakesList[65].toLowerCase()))
        { metaMake = metaMakesList[65];}
        else if (title.toLowerCase().contains(metaMakesList[66].toLowerCase()))
        { metaMake = metaMakesList[66];}
        else if (title.toLowerCase().contains(metaMakesList[67].toLowerCase()))
        { metaMake = metaMakesList[67];}
        else if (title.toLowerCase().contains(metaMakesList[68].toLowerCase()))
        { metaMake = metaMakesList[68];}
        else if (title.toLowerCase().contains(metaMakesList[69].toLowerCase()))
        { metaMake = metaMakesList[69];}
        else if (title.toLowerCase().contains(metaMakesList[70].toLowerCase()))
        { metaMake = metaMakesList[70];}
        else if (title.toLowerCase().contains(metaMakesList[71].toLowerCase()))
        { metaMake = metaMakesList[71];}
        else if (title.toLowerCase().contains(metaMakesList[72].toLowerCase()))
        { metaMake = metaMakesList[72];}
        else if (title.toLowerCase().contains(metaMakesList[73].toLowerCase()))
        { metaMake = metaMakesList[73];}
        else if (title.toLowerCase().contains(metaMakesList[74].toLowerCase()))
        { metaMake = metaMakesList[74];}
        else if (title.toLowerCase().contains(metaMakesList[75].toLowerCase()))
        { metaMake = metaMakesList[75];}
        else if (title.toLowerCase().contains(metaMakesList[76].toLowerCase()))
        { metaMake = metaMakesList[76];}
        else if (title.toLowerCase().contains(metaMakesList[77].toLowerCase()))
        { metaMake = metaMakesList[77];}
        else if (title.toLowerCase().contains(metaMakesList[78].toLowerCase()))
        { metaMake = metaMakesList[78];}
        else if (title.toLowerCase().contains(metaMakesList[79].toLowerCase()))
        { metaMake = metaMakesList[79];}
        else if (title.toLowerCase().contains(metaMakesList[80].toLowerCase()))
        { metaMake = metaMakesList[80];}
        else if (title.toLowerCase().contains(metaMakesList[81].toLowerCase()))
        { metaMake = metaMakesList[81];}
        else if (title.toLowerCase().contains(metaMakesList[82].toLowerCase()))
        { metaMake = metaMakesList[82];}
        else if (title.toLowerCase().contains(metaMakesList[83].toLowerCase()))
        { metaMake = metaMakesList[83];}
        else if (title.toLowerCase().contains(metaMakesList[84].toLowerCase()))
        { metaMake = metaMakesList[84];}
        else if (title.toLowerCase().contains(metaMakesList[85].toLowerCase()))
        { metaMake = metaMakesList[85];}
        else if (title.toLowerCase().contains(metaMakesList[86].toLowerCase()))
        { metaMake = metaMakesList[86];}
        else if (title.toLowerCase().contains(metaMakesList[87].toLowerCase()))
        { metaMake = metaMakesList[87];}
        else if (title.toLowerCase().contains(metaMakesList[88].toLowerCase()))
        { metaMake = metaMakesList[88];}
        else if (title.toLowerCase().contains(metaMakesList[89].toLowerCase()))
        { metaMake = metaMakesList[89];}
        else if (title.toLowerCase().contains(metaMakesList[90].toLowerCase()))
        { metaMake = metaMakesList[90];}
        else if (title.toLowerCase().contains(metaMakesList[91].toLowerCase()))
        { metaMake = metaMakesList[91];}
        else if (title.toLowerCase().contains(metaMakesList[92].toLowerCase()))
        { metaMake = metaMakesList[92];}
        else if (title.toLowerCase().contains(metaMakesList[93].toLowerCase()))
        { metaMake = metaMakesList[93];}
        else if (title.toLowerCase().contains(metaMakesList[94].toLowerCase()))
        { metaMake = metaMakesList[94];}
        else if (title.toLowerCase().contains(metaMakesList[95].toLowerCase()))
        { metaMake = metaMakesList[95];}
        else if (title.toLowerCase().contains(metaMakesList[96].toLowerCase()))
        { metaMake = metaMakesList[96];}
        else if (title.toLowerCase().contains(metaMakesList[97].toLowerCase()))
        { metaMake = metaMakesList[97];}
        else if (title.toLowerCase().contains(metaMakesList[98].toLowerCase()))
        { metaMake = metaMakesList[98];}
        else if (title.toLowerCase().contains(metaMakesList[99].toLowerCase()))
        { metaMake = metaMakesList[99];}
        else if (title.toLowerCase().contains(metaMakesList[100].toLowerCase()))
        { metaMake = metaMakesList[100];}
        else if (title.toLowerCase().contains(metaMakesList[101].toLowerCase()))
        { metaMake = metaMakesList[101];}
        else if (title.toLowerCase().contains(metaMakesList[102].toLowerCase()))
        { metaMake = metaMakesList[102];}
        else if (title.toLowerCase().contains(metaMakesList[103].toLowerCase()))
        { metaMake = metaMakesList[103];}
        else if (title.toLowerCase().contains(metaMakesList[104].toLowerCase()))
        { metaMake = metaMakesList[104];}
        else if (title.toLowerCase().contains(metaMakesList[105].toLowerCase()))
        { metaMake = metaMakesList[105];}
        else if (title.toLowerCase().contains(metaMakesList[106].toLowerCase()))
        { metaMake = metaMakesList[106];}
        else if (title.toLowerCase().contains(metaMakesList[107].toLowerCase()))
        { metaMake = metaMakesList[107];}
        else if (title.toLowerCase().contains(metaMakesList[108].toLowerCase()))
        { metaMake = metaMakesList[108];}
        else if (title.toLowerCase().contains(metaMakesList[109].toLowerCase()))
        { metaMake = metaMakesList[109];}
        else if (title.toLowerCase().contains(metaMakesList[110].toLowerCase()))
        { metaMake = metaMakesList[110];}
        else if (title.toLowerCase().contains(metaMakesList[111].toLowerCase()))
        { metaMake = metaMakesList[111];}
        else {
            metaMake = defaultstring;
        }
     
        if (title.toLowerCase().contains(scaleList[0].toLowerCase()))
        { scale = scaleList[0]; }
        else if (title.toLowerCase().contains(scaleList[1].toLowerCase()))
        { scale = scaleList[1]; }
        else if (title.toLowerCase().contains(scaleList[2].toLowerCase()))
        { scale = scaleList[2]; }
        else if (title.toLowerCase().contains(scaleList[3].toLowerCase()))
        { scale = scaleList[3]; }
        else if (title.toLowerCase().contains(scaleList[4].toLowerCase()))
        { scale = scaleList[4]; }
        else if (title.toLowerCase().contains(scaleList[5].toLowerCase()))
        { scale = scaleList[5]; }
        else if (title.toLowerCase().contains(scaleList[6].toLowerCase()))
        { scale = scaleList[6]; }
        else if (title.toLowerCase().contains(scaleList[7].toLowerCase()))
        { scale = scaleList[7]; }
        else if (title.toLowerCase().contains(scaleList[8].toLowerCase()))
        { scale = scaleList[8]; }
        else if (title.toLowerCase().contains(scaleList[9].toLowerCase()))
        { scale = scaleList[9]; }
        else if (title.toLowerCase().contains(scaleList[10].toLowerCase()))
        { scale = scaleList[10]; }
        else if (title.toLowerCase().contains(scaleList[11].toLowerCase()))
        { scale = scaleList[11]; }
     
        else { scale = defaultstring;}
     
        if (title.toLowerCase().contains(diecastManuList[0].toLowerCase()))
        { diecastManu = diecastManuList[0]; }
        else if (title.toLowerCase().contains(diecastManuList[1].toLowerCase()))
        { diecastManu = diecastManuList[1]; }
        else if (title.toLowerCase().contains(diecastManuList[2].toLowerCase()))
        { diecastManu = diecastManuList[2]; }
        else if (title.toLowerCase().contains(diecastManuList[3].toLowerCase()))
        { diecastManu = diecastManuList[3]; }
        else if (title.toLowerCase().contains(diecastManuList[4].toLowerCase()))
        { diecastManu = diecastManuList[4]; }
        else if (title.toLowerCase().contains(diecastManuList[5].toLowerCase()))
        { diecastManu = diecastManuList[5]; }
        else if (title.toLowerCase().contains(diecastManuList[6].toLowerCase()))
        { diecastManu = diecastManuList[6]; }
        else if (title.toLowerCase().contains(diecastManuList[7].toLowerCase()))
        { diecastManu = diecastManuList[7]; }
        else if (title.toLowerCase().contains(diecastManuList[8].toLowerCase()))
        { diecastManu = diecastManuList[8]; }
        else if (title.toLowerCase().contains(diecastManuList[9].toLowerCase()))
        { diecastManu = diecastManuList[9]; }
        else if (title.toLowerCase().contains(diecastManuList[10].toLowerCase()))
        { diecastManu = diecastManuList[10]; }
        else if (title.toLowerCase().contains(diecastManuList[11].toLowerCase()))
        { diecastManu = diecastManuList[11]; }
        else if (title.toLowerCase().contains(diecastManuList[12].toLowerCase()))
        { diecastManu = diecastManuList[12]; }
        else if (title.toLowerCase().contains(diecastManuList[13].toLowerCase()))
        { diecastManu = diecastManuList[13]; }
        else if (title.toLowerCase().contains(diecastManuList[14].toLowerCase()))
        { diecastManu = diecastManuList[14]; }
        else if (title.toLowerCase().contains(diecastManuList[15].toLowerCase()))
        { diecastManu = diecastManuList[15]; }
        else if (title.toLowerCase().contains(diecastManuList[16].toLowerCase()))
        { diecastManu = diecastManuList[16]; }
        else if (title.toLowerCase().contains(diecastManuList[17].toLowerCase()))
        { diecastManu = diecastManuList[17]; }
        else if (title.toLowerCase().contains(diecastManuList[18].toLowerCase()))
        { diecastManu = diecastManuList[18]; }
        else if (title.toLowerCase().contains(diecastManuList[19].toLowerCase()))
        { diecastManu = diecastManuList[19]; }
        else if (title.toLowerCase().contains(diecastManuList[20].toLowerCase()))
        { diecastManu = diecastManuList[20]; }
        else if (title.toLowerCase().contains(diecastManuList[21].toLowerCase()))
        { diecastManu = diecastManuList[21]; }
        else if (title.toLowerCase().contains(diecastManuList[22].toLowerCase()))
        { diecastManu = diecastManuList[22]; }
        else if (title.toLowerCase().contains(diecastManuList[23].toLowerCase()))
        { diecastManu = diecastManuList[23]; }
        else if (title.toLowerCase().contains(diecastManuList[24].toLowerCase()))
        { diecastManu = diecastManuList[24]; }
        else if (title.toLowerCase().contains(diecastManuList[25].toLowerCase()))
        { diecastManu = diecastManuList[25]; }
        else if (title.toLowerCase().contains(diecastManuList[26].toLowerCase()))
        { diecastManu = diecastManuList[26]; }
        else if (title.toLowerCase().contains(diecastManuList[27].toLowerCase()))
        { diecastManu = diecastManuList[27]; }
        else if (title.toLowerCase().contains(diecastManuList[28].toLowerCase()))
        { diecastManu = diecastManuList[28]; }
        else if (title.toLowerCase().contains(diecastManuList[29].toLowerCase()))
        { diecastManu = diecastManuList[29]; }
        else if (title.toLowerCase().contains(diecastManuList[30].toLowerCase()))
        { diecastManu = diecastManuList[30]; }
        else if (title.toLowerCase().contains(diecastManuList[31].toLowerCase()))
        { diecastManu = diecastManuList[31]; }
        else if (title.toLowerCase().contains(diecastManuList[32].toLowerCase()))
        { diecastManu = diecastManuList[32]; }
        else if (title.toLowerCase().contains(diecastManuList[33].toLowerCase()))
        { diecastManu = diecastManuList[33]; }
        else if (title.toLowerCase().contains(diecastManuList[34].toLowerCase()))
        { diecastManu = diecastManuList[34]; }
        else if (title.toLowerCase().contains(diecastManuList[35].toLowerCase()))
        { diecastManu = diecastManuList[35]; }
        else if (title.toLowerCase().contains(diecastManuList[36].toLowerCase()))
        { diecastManu = diecastManuList[36]; }
        else if (title.toLowerCase().contains(diecastManuList[37].toLowerCase()))
        { diecastManu = diecastManuList[37]; }
        else if (title.toLowerCase().contains(diecastManuList[38].toLowerCase()))
        { diecastManu = diecastManuList[38]; }
        else if (title.toLowerCase().contains(diecastManuList[39].toLowerCase()))
        { diecastManu = diecastManuList[39]; }
        else if (title.toLowerCase().contains(diecastManuList[40].toLowerCase()))
        { diecastManu = diecastManuList[40]; }
        else if (title.toLowerCase().contains(diecastManuList[41].toLowerCase()))
        { diecastManu = diecastManuList[41]; }
        else if (title.toLowerCase().contains(diecastManuList[42].toLowerCase()))
        { diecastManu = diecastManuList[42]; }
        else if (title.toLowerCase().contains(diecastManuList[43].toLowerCase()))
        { diecastManu = diecastManuList[43]; }
        else if (title.toLowerCase().contains(diecastManuList[44].toLowerCase()))
        { diecastManu = diecastManuList[44]; }
        else if (title.toLowerCase().contains(diecastManuList[45].toLowerCase()))
        { diecastManu = diecastManuList[45]; }
        else if (title.toLowerCase().contains(diecastManuList[46].toLowerCase()))
        { diecastManu = diecastManuList[46]; }
        else if (title.toLowerCase().contains(diecastManuList[47].toLowerCase()))
        { diecastManu = diecastManuList[47]; }
        else if (title.toLowerCase().contains(diecastManuList[48].toLowerCase()))
        { diecastManu = diecastManuList[48]; }
        else if (title.toLowerCase().contains(diecastManuList[49].toLowerCase()))
        { diecastManu = diecastManuList[49]; }
        else if (title.toLowerCase().contains(diecastManuList[50].toLowerCase()))
        { diecastManu = diecastManuList[50]; }
        else if (title.toLowerCase().contains(diecastManuList[51].toLowerCase()))
        { diecastManu = diecastManuList[51]; }
        else if (title.toLowerCase().contains(diecastManuList[52].toLowerCase()))
        { diecastManu = diecastManuList[52]; }
        else {
            diecastManu = defaultstring;
        }
     
     
     
        System.out.println("Please paste car model (e.g Skyline).");
        metaModel = sc.nextLine();
     
     
    String fullOutput = "<METANAME="  + "\"DESCRIPTION\"" + "CONTENT=\"" + "Shop for " + title + " "
            + "diecast model cars at [SITE REMOVED]\"" +">" + "\n"
                + "<METANAME="  + "\"ABSTRACT\"" + "CONTENT=" + abstr + "\n"
             +  "<METANAME="  + "\"KEYWORDS\"" + "CONTENT=" + "“diecast cars, diecast " + scale + " "
                    + "scale cars," + "\n" + "diecast model cars, modelcars, collectable cars, "
             + diecastManu + " diecast"
                            + " model, " + metaMake + " diecast cars, diecast " + metaModel +"\">";
     
    System.out.println(fullOutput);
     
    System.out.println("Press 'y' to run again.");
    String asker = sc.next();
    if (asker.equalsIgnoreCase("y"))
    { keepRunning = true;}
    else { keepRunning = false;}
    }

    Sample input/output:

    INPUT:
    Maisto Ford Mustang 1:18 Red
    OUTPUT:
    <METANAME="DESCRIPTION"CONTENT="Shop for Maisto Ford Mustang 1:18 Red diecast model cars at [SITE]">
    <METANAME="ABSTRACT"CONTENT=Shop for diecast model cars at [SITE].>
    <METANAME="KEYWORDS"CONTENT=“diecast cars, diecast 1:18 scale cars,
    diecast model cars, modelcars, collectable cars, Maisto diecast model, Ford diecast cars, diecast Mustang">

    ^ This works fine. That's the desired result. The problem is with other brands, even though the if statements are identical for every brand. For example

    INPUT
    AUTOart Hummer H2 1:18 Blue
    OUTPUT
    <METANAME="DESCRIPTION"CONTENT="Shop for AUTOart Hummer H2 1:18 Blue diecast model cars at [SITE]">
    <METANAME="ABSTRACT"CONTENT=Shop for diecast model cars at [SITE].>
    <METANAME="KEYWORDS"CONTENT=“diecast cars, diecast 1:18 scale cars,
    diecast model cars, modelcars, collectable cars, quality diecast model, quality diecast cars, diecast H2">

    This one should say, if the program was functioning correctly:

    <METANAME="DESCRIPTION"CONTENT="Shop for AUTOart Hummer H2 1:18 Blue diecast model cars at [SITE]">
    <METANAME="ABSTRACT"CONTENT=Shop for diecast model cars at [SITE].>
    <METANAME="KEYWORDS"CONTENT=“diecast cars, diecast 1:18 scale cars,
    diecast model cars, modelcars, collectable cars, AUTOart diecast model, Hummer diecast cars, diecast H2">
    Last edited by BenjaminJ; September 13th, 2014 at 09:21 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Identical if statements behaving in different ways

    Try doing some debugging. For example add some println() statements that print out the contents of the title variable so you can see what the code is working with when the if statements are executed. Be sure to add delimiters: S.o.p("title=" + title +"<"); to show leading or trailing spaces.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Identical if statements behaving in different ways

    I would really advice you to learn about for-loops. They would cut down your code tremendously.

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: Identical if statements behaving in different ways

    Quote Originally Posted by Cornix View Post
    I would really advice you to learn about for-loops. They would cut down your code tremendously.
    You're right, I've reduced the block of if statements to nine lines in total. And the problem, originally, was the way I joined new lines with +s instead of just pressing enter and typing a comma.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Identical if statements behaving in different ways

    All fixed then? You can mark the thread "Solved" if so. Otherwise, ask a question.

  6. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: Identical if statements behaving in different ways

    Well, another issue has come up. For example with a model of a 'GT500' the program reacts by matching that first with 'GT' and settling with that. I've tried '.contains', I've tried .indexOf != -1, .lastIndexOf, etc.

    Is there a method which will match the entire string/token not just the first substring which comes up?

  7. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Identical if statements behaving in different ways

    Did you try .equals()? For other methods that may help, check the String API. Post updated code, especially the part you're asking for help with.

  8. #8
    Junior Member
    Join Date
    Jul 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: Identical if statements behaving in different ways

    This is the part I updated.

    	for (int i=0; i<scaleList.length; i++)
     
    			if (title.toLowerCase().lastIndexOf(scaleList[i].toLowerCase())!= -1)
     
    			{ scale = scaleList[i];
     
    			break;}

    .equals wouldn't work because I'm searching for a substring not a whole one. I've had a look at the String API, I'm can't find anything which matches my needs so I was thinking that I might need to make a custom method for it.

  9. #9
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Identical if statements behaving in different ways

    Please break it down to a problem we can understand, something like:

    My program needs to match this: <show the variable string from the pool of strings>
    to this: <show the string that the string above should match>
    but not to this: <if applicable>, or this . . . etc.

    I'm currently using this statement: <show the existing statement(s) that is/are not working>
    but getting the following undesired results: <show/describe those>

  10. #10
    Junior Member
    Join Date
    Jul 2014
    Posts
    27
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: Identical if statements behaving in different ways

    Okay, so, my program needs to match this: Maisto Ford Mustang Limited Edition 1:18 Red
    with "Mustang" but not to "Ion"

    Sample input and output:

    INPUT:

    Maisto Ford Mustang Limited Edition 1:18 Red

    OUTPUT:

    <METANAME="DESCRIPTION"CONTENT="Shop for Maisto Ford Mustang Limited Edition 1:18 Red diecast model cars at [SITE]>
    <METANAME="ABSTRACT"CONTENT=Shop for diecast model cars at [SITE]>
    <METANAME="KEYWORDS"CONTENT=“diecast cars, diecast 1:18 scale cars,
    diecast model cars, modelcars, collectable cars, Maisto diecast model, Ford diecast cars, diecast Ion">

    I think it is because the array is in alphabetical order and it takes the 'I' before the 'M'

    import java.util.Scanner;
    public class MetagenV5 {
     
    	private static boolean keepRunning;
     
    	public static void main (String[] args) {
     
    		do {
    		GenerateData(); }
    		while (keepRunning = true);
    		if (keepRunning = false) {
    			System.exit(0);
    		}
    	}
     
    		public static void GenerateData() {
     
    		Scanner sc = new Scanner(System.in);
    		String title = null;
    		String abstr = "Shop for diecast model cars at [SITE].>";
    		String scale = null;
    		String diecastManu = null;
    		String metaModel = null;
    		String metaMake = null;
    		String defaultString = "quality";
     
    		String[] metaMakesList = {"Abarth", "Acura", "Ahrens", "Alfa Romeo",
    				"Alpine Renault", "AMC", "American LaFrance", "Aprilia", "Aston Martin" ,
    				"Audi", "Austin", "Austin-Healey", "Bedford", "Benelli", "Bentley", "BMW",
    				"Buffalo", "Bugatti", "Buick","Cadillac","Caterham", "Chaparrel",
    				 "Checker","Chevrolet","Chrysler","Citroen", "Cleveland", "Cord","DAF",
    				"Daimler","Dakota","Datsun","Dauer","De Soto", "Delahaye", "DeLorean", "Dennis", "Divco",
    				"Dodge", "Duesenberg", "Edsel", "F1", "Ferrari","Fiat","Ford","Freightliner",
    				"GAZ", "GMC", "Gumpert", "Halo", "Helicopter","Hello Kitty", "Honda","Horch","Hudson",
    				"Hummer","Hyundai","Infiniti", "International", "Jaguar", "Jeep", "K2", "Kaiser",
    				"Koenigsegg","Lamborghini","Lancia","Land Rover", "LandRover", "Lexus","Leyland",
    				"Lincoln", "Lotus","Mack","Magirus-Deutz","Maserati","Maxim", "Maybach",
    				"Mazda","McLaren","Mercedes-Benz","Mercedes Benz","Mercedes","Mercury","Messerschmitt",
    				"Meyers Manxter","MG","Mini","Mini Cooper","Mitsubishi","Morgan","Morris",
    				"Nash", "Nissan","Oldsmobile","Opel","Packard","Pagani","Panhard","Panoz","Pantera",
    				"Peugeot","Pierce-Arrow","Plymouth","Pontiac","Porsche","Puegoet","Renault","Reo",
    				"Rolls Royce", "Rolls-Royce","Saturn","Scion","Seagrave","Seat","Simca", "Smart",
    				"Studebaker","Stutz", "Subaru","Tata","Toyota","Triumph","Tucker","TVR","TX1",
    				"VolksWagen","Volvo","White","Willys"};
     
    		String[] scaleList = {"1:12","1:18","1:24","1:32","1:25","1:34","1:43","1:64","1/12", "1/18", "1/24","1/25", "1/32","1/34", "1/43", "1/64"};
     
    		String[] diecastManuList = {"Muscle Machines","Jada Toys",
    				        "AUTOart","Kinsmart","M2","1BaddRide",
    						"Greenlight","Anson","Arko","Auto World",
    						"Bauer","BBR","BBurago","Carney Plastics",
    						"Collectable Diecast","CMC","Double Horse",
    						"Elvis Motor Classics","Classic Metal Works",
    						"Ertl","Fast Women","First Gear","GMP","Hawk",
    						"Highway 61","Hot Wheels","Hot Works","IXO",
    						"Johnny Lightning","Kustom City","Kyosho",
    						"LandMice","Lane Exact Detail","Liberty Classics",
    						"LJP","Luxury","Lindberg","Maisto","Minichamps",
    						"Mira-Solido","MJX","Mondo Motors","Motor City",
    						"Motorhead","Motormax","New Ray","Norev",
    						"Paragon","Paudi","Pioneer","Phoenix Mint",
    						"Precision Miniatures","Revell","Ricko Ricko",
    						"RMZ City","Road Mice","Saico","Schuco","Shelby Collectibles",
    						"Signature","So Real Concepts","SpecCast",
    						"SunStar","Superior","Syma","True Scale",
    						"Unique Replicas","Universal Hobbies",
    						"Vitesse","XQ","Yat-Ming","Welly"};
     
    		String[] metaModelList = {"500","A3", "A4", "A5", "A6", "A7", "A8", "Acadia", "Accent", "Acclaim", "Accord", "Achieva", "Aerio", "Aero", "Aerostar", "Alcyone", "Alero", "Allante", "Alliance", "Allroad", "Alpina", "Altima", "Amanti", "Amigo", "APV", "Aries", "Armada", "Arnage", "Ascender", "Aspen", "Aspire", "Astra", "Astro", "Aura", "Aurora", "Avalanche", "Avalon", "Avanti", "Avenger", "Aventador", "Aveo", "Aviator", "Axiom", "Azera", "Aztek", "Azure", "B-Series", "B-Series", "B2000", "B2500", "B2600", "B9", "Baja", "Beetle", "Bel Air", "Belair", "Beretta", "Biturbo", "Blackwood", "Blazer", "Bonneville", "Borrego", "Boxster", "Brat", "Bravada", "Breeze", "Bronco", "Brooklands", "Brougham", "BRZ", "C-Class", "C-MAX", "C/V", "C30", "C70", "C8", "Caliber", "California", "Camaro", "Camry", "Canyon", "Capri", "Caprice", "Caravan", "Carens", "Carrera", "Catera", "Cayenne", "Cayman", "CC", "Celica", "Century", "Challenger", "Charade", "Charger", "Chariot", "Cherokee", "Chevette", "Ciera", "Cirrus", "Citation","Civic", "CL-Class", "CL", "CL65", "CLK-Class", "CLS-Class", "Club", "Clubman", "Coachbuilder", "Cobalt", "Colorado", "Colt","Comanche", "Commander", "Compass", "Concorde","Continental", "Contour", "Cooper", "Cordia", "Corolla", "Corrado", "Corsica", "Corsica", "Corvair", "Corvette", "Cougar", "Countach", "Country", "Countryman","Coupe", "Courier", "CR-V", "CR-X", "Cressida", "Crossfire", "Crosstour", "Crown", "Cruze", "CT", "CTS-V", "CTS", "Cube", "Cultus", "Custom", "Cutlass", "CX-5", "CX-7", "CX-9", "CX", "D150",  "D250", "D350", "Daewoo", "Dakota", "Daytona", "DB9", "DBS",  "Defender", "Del", "DeVille", "Diablo", "Diamante","Discovery", "DTS", "Durango", "Dynasty", "E-350", "E-Class", "E-Series", "E150", "E250", "E350", "Echo", "Eclipse",  "Econoline", "Edge", "Elan", "Elantra", "Elantra", "Eldorado", "Electra", "Element", "Elise", "Enclave", "Endeavor", "Entourage",  "Envoy", "Eos", "Equator", "Equinox", "Equus",  "Escalade", "Escape", "Escort", "Esperante", "Esprit", "Estate", "Esteem", "Eurovan", "EV1", "Evora", "EX", "Excel", "Excursion",  "Exige", "EXP",  "Expedition",  "Explorer","Expo", "Express", "F-250", "F-350", "F-Series", "F150", "F150", "F250", "F350", "F350", "F430", "F450", "Fairlane", "Falcon", "Familia", "FCX", "Festiva", "FF", "Fiero", "Fiesta", "Fifth", "Fillmore", "Firebird", "Firefly", "Fit", "Five", "FJ", "Fleetwood", "Flex", "Focus", "Forenza", "Forester", "Forte", "Fortwo", "Fox", "FR-S", "Freelander", "Freestar", "Freestyle", "Frontier", "Fury", "Fusion", "FX", "G-Class",  "G-Series", "G25", "G3", "G35", "G37", "G5", "G55", "G6", "G8", "Galant", "Galaxie", "Gallardo", "Gemini", "Genesis", "Ghost", "GL-Class", "GLC", "GLI", "GLK-Class","Golf", "Gran","Grand","GranSport", "GranTurismo", "GS", "GT-R", "GT", "GT350", "GT500", "GTI", "GTO", "GX", "GX", "H1", "H2", "H3", "H3T", "Hearse", "HED-5", "Hemisfear",  "HHR",  "Highlander", "Hombre", "Horizon", "HS", "i-280", "i-350", "i-MiEV", "i-Series", "Ice", "Impala", "Imperial", "Impreza", "Impulse", "Insight", "Integra", "Interceptor", "Intrepid", "Intrigue", "Intrigue", "Ion", "IPL", "Ipsum", "iQ", "IS-F",  "Jetta", "Jimmy", "Journey", "JUKE", "Justy", "JX", "K5", "Karif", "Kizashi", "L-Series", "L300", "LaCrosse", "Lancer", "Landaulet", "Lanos", "Laser", "Leaf", "LeBaron", "Legacy", "Leganza", "Legend", "LeMans", "Leone", "LeSabre", "LFA", "LHS", "LHS", "Liberty", "Lightning", "Loyale", "LR2", "LR3", "LR4",  "LSS", "Lucerne",  "Lumina", "LUV", "LX", "Lynx", "M-Class", "M3", "M5", "M6", "Magnum","Malibu", "Marauder", "Mariner", "Mark", "Marquis", "Matrix", "Maxima", "Mazda2", "Mazda3", "Mazda5",  "Mazda6", "Mazdaspeed6", "MDX", "Mentor", "Metro", "MGB", "Miata",  "Mighty", "Milan", "Millenia",  "Mini", "Minx", "Mirage", "MKT", "MKX", "MKZ", "Monaco", "Montana", "Monte", "Montego", "Monterey", "Montero", "Monza", "Mountaineer", "MP4-12C", "MR2", "Mulsanne", "Murano", "Murcielago", "Mustang", "MX-3", "MX-5", "MX-6", "Mystique", "Navajo", "Navigator", "Neon","Nitro", "NSX", "Nubira", "Nuova", "NV1500", "NV2500", "NV3500", "NX", "Oasis", "Odyssey", "Omni", "Optima", "Outback", "Outback", "Outlander", "Pacifica", "Pajero", "Panamera", "Parisienne", "Park", "Paseo", "Passat", "Passport", "Pathfinder", "Patriot", "Patriot", "Phaeton", "Phantom", "Pilot", "Precis", "Prelude", "Premier", "Previa","Prius", "Prizm", "Probe", "Protege", "Protege5", "Prowler", "PT",  "Q5", "Q7", "Quantum", "Quattro", "Quattroporte", "Quest", "QX", "QX56", "R-Class", "R32", "R8", "Rabbit", "Raider", "Rainier",  "Ram", "Ramcharger", "Ramcharger",  "Range", "Ranger", "Rapide", "RAV4", "RDX", "Reatta", "Regal", "Regency", "Relay", "Reliant", "Rendezvous", "Reno", "Reventón", "Ridgeline", "rio", "Rio5", "riolet", "Riviera", "RL", "Roadmaster", "Roadrunner", "Roadster", "Rockette", "Rocky", "Rodeo",  "Rogue", "Rondo", "Routan",  "RS4", "RS6", "RSX", "RVR", "RX-7", "RX-8", "RX", "S-Class", "S-Series", "S-Type", "S10", "S2000", "S4", "S40", "S6", "S70", "S8", "S80", "Sable", "Safari", "Samurai", "Santa", "Savana", "SC", "Scirocco", "Scoupe", "Sebring", "Sedona", "Sentra", "Sephia", "Sequoia", "Seville", "Shadow", "Sidekick", "Sienna",  "Sierra", "Sigma", "Silhouette", "Sixty", "SJ", "Sky", "Skyhawk", "Skylark", "SL-Class", "SL65", "SLK-Class", "SLK55", "SLR", "SLS", "SLS-Class", "SM", "Solara", "Solstice", "Somerset", "Sonata", "Sonic", "Sonoma", "Sorento", "Soul", "Space", "Sparrow", "Special", "Spectra", "Spectra5", "Spider", "Spirit", "Sportage",  "Sportvan", "Sprinter", "Spyder", "SRX", "SSR", "Stanza", "Sterling", "Storm", "Stratus", "STS-V", "STS", "Stylus", "Suburban", "Summit", "Sunbird", "Sundance", "Sunfire", "Supra", "SVX", "Swift", "SX4", "T100", "Tacoma", "Tahoe", "Talon",  "Taurus", "tC", "Tempest", "Tempo", "Terrain", "Terraza", "Th!nk", "Thunderbird", "Tiburon", "Tiguan", "Titan", "TL", "Torino", "Toronado", "Torrent",  "Touareg",  "Town", "Tracer", "Tracker", "Trailblazer", "Transit", "Traverse", "Tredia", "Tribeca", "Tribute", "Trooper",  "Truck", "TSX", "TT", "Tucson", "Tundra", "TundraMax",  "Typ-1", "Type-1h", "Uplander", "V40", "V50", "V70", "V90", "Vanagon",  "Vandura", "Vanquish", "Vantage", "Vega", "VehiCROSS", "Veloster", "Venture", "Venza", "Veracruz", "Verano", "Versa", "Veyron", "Vibe", "Vigor", "Vigor", "Villager", "Viper", "Virage", "Vision", "Vitara", "Volare", "Volt", "Voyager", "VS", "VUE", "W123", "W126", "W201", "Windstar", "Wrangler", "X-90", "X-Type", "X3",  "X5", "X6", "xA", "xB", "XC60", "XC70", "XC90", "xD", "XF", "XG300",  "XJ",  "XK", "XL-7", "XL7", "XLR-V", "XLR", "XR4Ti", "XT", "Xterra", "Xtra", "Yaris","Yukon","Z3", "Z4", "Z8", "ZDX", "Zephyr", "ZX2","Silverado"};
     
     
     
    		System.out.println("Please paste model title.");
    		title = sc.nextLine();
     
    		for (int i=0; i<metaMakesList.length; i++)
     
    			if (title.toLowerCase().lastIndexOf(metaMakesList[i].toLowerCase()) != -1)
     
    			{ metaMake = metaMakesList[i];
    			break;}
     
     
     
    		for (int i=0; i<scaleList.length; i++)
     
    			if (title.toLowerCase().lastIndexOf(scaleList[i].toLowerCase())!= -1)
     
    			{ scale = scaleList[i];
     
    			break;}
     
    	for (int i=0; i<diecastManuList.length; i++)
     
    			if (title.toLowerCase().lastIndexOf(diecastManuList[i].toLowerCase())!= -1)
     
    			{ diecastManu = diecastManuList[i];
     
    			break;}
     
    	for (int i=0; i<metaModelList.length; i++)
     
    		if (title.toLowerCase().lastIndexOf(metaModelList[i].toLowerCase())!= -1)
     
    		{ metaModel = metaModelList[i];
     
    		break;}
     
     
     
     
     
     
     
     
    	String fullOutput =	"<METANAME="  + "\"DESCRIPTION\"" + "CONTENT=\"" + "Shop for " + title + " "
    			+ "diecast model cars at [SITE]\"" +">" + "\n"
    				+ "<METANAME="  + "\"ABSTRACT\"" + "CONTENT=" + abstr + "\n"
    			 +	"<METANAME="  + "\"KEYWORDS\"" + "CONTENT=" + "“diecast cars, diecast " + scale + " "
    			 		+ "scale cars," + "\n" + "diecast model cars, modelcars, collectable cars, "
    			 + diecastManu + " diecast"
    			 				+ " model, " + metaMake + " diecast cars, diecast " + metaModel +"\">";
     
    	System.out.println(fullOutput);
     
    	System.out.println("Press 'y' to run again.");
    	String asker = sc.next();
    	if (asker.equalsIgnoreCase("y"))
    	{ keepRunning = true;}
    	else { keepRunning = false;}
    	}
    }

  11. #11
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Identical if statements behaving in different ways

    I suggest you consider changing the approach from finding a specific match of a search string to a target string to one that chooses the result with the highest score or relevance out of some number of possible results. There may be search elements that are absolutely required and others that are desired but less significant, and the combination of the required plus some less significant could be used to create a relevance score.

    Fudging the search criteria to fit the data might work for a small set of data for a short time, but when the character of the data changes more fudging will be required. Google has done a lot of research in this area, I imagine little of their results have been released into the open, but perhaps some of their basic search theory and/or rules have been shared. You should look.

  12. The Following User Says Thank You to GregBrannon For This Useful Post:

    BenjaminJ (September 18th, 2014)

Similar Threads

  1. my do while isn't behaving (beginner)
    By meangreen2003 in forum Loops & Control Statements
    Replies: 8
    Last Post: June 1st, 2014, 01:59 PM
  2. Excel RATE() function in Java behaving a bit differently
    By capricorn86 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 23rd, 2014, 06:18 AM
  3. [SOLVED] NoSuchElementException(), simple program not behaving right with Scanner class.
    By mwebb in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 25th, 2011, 06:41 PM
  4. [SOLVED] If, else if, else statement not behaving as expected
    By techwiz24 in forum Loops & Control Statements
    Replies: 5
    Last Post: April 15th, 2011, 12:02 PM
  5. Multiple Identical Scripts - Variables and Load Handlers
    By cas22 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2011, 11:37 AM