problem with the result of a two-dimensional array












-2














    char tab = {
{'S', 'a', 'm', 's', 'u', 'n', 'g'},
{'N', 'o', 'k', 'i', 'a'},
{'A', 'p', 'p', 'l', 'e'},
{'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
{'A', 'l', 'c', 'a', 't', 'e', 'l'},
{'S', 'o', 'n', 'y'},
{'J', 'o', 'l', 'l', 'a'},
};

int letters = 0;
int k = 0;
int licz = 0;

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if (tab[i][j] == tab[i][k]) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two identical letters");
System.out.println();
}
letters = 0;
}
}

System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
licz += (int) (tab[i][j]);
}
if (licz > 255) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" sum of characters in the word > 255");
System.out.println();
}

licz = 0;

}

letters = 0;
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
if (tab[i][j] == 'i')
letters++;
}
if (letters > 0) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there is at least one character 'i'");
System.out.println();
}

letters = 0;

}
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two of the same characters");
System.out.println();
}
letters = 0;
}
}


Why does my program display a different result than expected?



the same characters an letters for BlackBerry, why?



result:



in this word : Apple there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : Jolla there are at least two identical letters



in this word : Samsung sum of characters in the word > 255



in this word : Nokia sum of characters in the word > 255



in this word : Apple sum of characters in the word > 255



in this word : BlackBerry sum of characters in the word > 255



in this word : Alcatel sum of characters in the word > 255



in this word : Sony sum of characters in the word > 255



in this word : Jolla sum of characters in the word > 255



in this word : Nokia there is at least one character 'i'



in this word : Samsung there are at least two of the same characters



in this word : Apple there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : Alcatel there are at least two of the same characters



in this word : Jolla there are at least two of the same characters










share|improve this question


















  • 2




    What is the expected result?
    – GBlodgett
    Nov 12 at 18:47






  • 1




    You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
    – Peter Lawrey
    Nov 12 at 18:48










  • How should the code look like?
    – Foxal
    Nov 12 at 18:56
















-2














    char tab = {
{'S', 'a', 'm', 's', 'u', 'n', 'g'},
{'N', 'o', 'k', 'i', 'a'},
{'A', 'p', 'p', 'l', 'e'},
{'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
{'A', 'l', 'c', 'a', 't', 'e', 'l'},
{'S', 'o', 'n', 'y'},
{'J', 'o', 'l', 'l', 'a'},
};

int letters = 0;
int k = 0;
int licz = 0;

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if (tab[i][j] == tab[i][k]) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two identical letters");
System.out.println();
}
letters = 0;
}
}

System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
licz += (int) (tab[i][j]);
}
if (licz > 255) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" sum of characters in the word > 255");
System.out.println();
}

licz = 0;

}

letters = 0;
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
if (tab[i][j] == 'i')
letters++;
}
if (letters > 0) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there is at least one character 'i'");
System.out.println();
}

letters = 0;

}
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two of the same characters");
System.out.println();
}
letters = 0;
}
}


Why does my program display a different result than expected?



the same characters an letters for BlackBerry, why?



result:



in this word : Apple there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : Jolla there are at least two identical letters



in this word : Samsung sum of characters in the word > 255



in this word : Nokia sum of characters in the word > 255



in this word : Apple sum of characters in the word > 255



in this word : BlackBerry sum of characters in the word > 255



in this word : Alcatel sum of characters in the word > 255



in this word : Sony sum of characters in the word > 255



in this word : Jolla sum of characters in the word > 255



in this word : Nokia there is at least one character 'i'



in this word : Samsung there are at least two of the same characters



in this word : Apple there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : Alcatel there are at least two of the same characters



in this word : Jolla there are at least two of the same characters










share|improve this question


















  • 2




    What is the expected result?
    – GBlodgett
    Nov 12 at 18:47






  • 1




    You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
    – Peter Lawrey
    Nov 12 at 18:48










  • How should the code look like?
    – Foxal
    Nov 12 at 18:56














-2












-2








-2







    char tab = {
{'S', 'a', 'm', 's', 'u', 'n', 'g'},
{'N', 'o', 'k', 'i', 'a'},
{'A', 'p', 'p', 'l', 'e'},
{'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
{'A', 'l', 'c', 'a', 't', 'e', 'l'},
{'S', 'o', 'n', 'y'},
{'J', 'o', 'l', 'l', 'a'},
};

int letters = 0;
int k = 0;
int licz = 0;

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if (tab[i][j] == tab[i][k]) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two identical letters");
System.out.println();
}
letters = 0;
}
}

System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
licz += (int) (tab[i][j]);
}
if (licz > 255) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" sum of characters in the word > 255");
System.out.println();
}

licz = 0;

}

letters = 0;
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
if (tab[i][j] == 'i')
letters++;
}
if (letters > 0) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there is at least one character 'i'");
System.out.println();
}

letters = 0;

}
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two of the same characters");
System.out.println();
}
letters = 0;
}
}


Why does my program display a different result than expected?



the same characters an letters for BlackBerry, why?



result:



in this word : Apple there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : Jolla there are at least two identical letters



in this word : Samsung sum of characters in the word > 255



in this word : Nokia sum of characters in the word > 255



in this word : Apple sum of characters in the word > 255



in this word : BlackBerry sum of characters in the word > 255



in this word : Alcatel sum of characters in the word > 255



in this word : Sony sum of characters in the word > 255



in this word : Jolla sum of characters in the word > 255



in this word : Nokia there is at least one character 'i'



in this word : Samsung there are at least two of the same characters



in this word : Apple there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : Alcatel there are at least two of the same characters



in this word : Jolla there are at least two of the same characters










share|improve this question













    char tab = {
{'S', 'a', 'm', 's', 'u', 'n', 'g'},
{'N', 'o', 'k', 'i', 'a'},
{'A', 'p', 'p', 'l', 'e'},
{'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
{'A', 'l', 'c', 'a', 't', 'e', 'l'},
{'S', 'o', 'n', 'y'},
{'J', 'o', 'l', 'l', 'a'},
};

int letters = 0;
int k = 0;
int licz = 0;

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if (tab[i][j] == tab[i][k]) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two identical letters");
System.out.println();
}
letters = 0;
}
}

System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
licz += (int) (tab[i][j]);
}
if (licz > 255) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" sum of characters in the word > 255");
System.out.println();
}

licz = 0;

}

letters = 0;
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
if (tab[i][j] == 'i')
letters++;
}
if (letters > 0) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there is at least one character 'i'");
System.out.println();
}

letters = 0;

}
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length; j++) {

k = j;
while (k < tab[i].length - 1) {
if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32) letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two of the same characters");
System.out.println();
}
letters = 0;
}
}


Why does my program display a different result than expected?



the same characters an letters for BlackBerry, why?



result:



in this word : Apple there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : BlackBerry there are at least two identical letters



in this word : Jolla there are at least two identical letters



in this word : Samsung sum of characters in the word > 255



in this word : Nokia sum of characters in the word > 255



in this word : Apple sum of characters in the word > 255



in this word : BlackBerry sum of characters in the word > 255



in this word : Alcatel sum of characters in the word > 255



in this word : Sony sum of characters in the word > 255



in this word : Jolla sum of characters in the word > 255



in this word : Nokia there is at least one character 'i'



in this word : Samsung there are at least two of the same characters



in this word : Apple there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : BlackBerry there are at least two of the same characters



in this word : Alcatel there are at least two of the same characters



in this word : Jolla there are at least two of the same characters







java arrays






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 18:45









Foxal

1




1








  • 2




    What is the expected result?
    – GBlodgett
    Nov 12 at 18:47






  • 1




    You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
    – Peter Lawrey
    Nov 12 at 18:48










  • How should the code look like?
    – Foxal
    Nov 12 at 18:56














  • 2




    What is the expected result?
    – GBlodgett
    Nov 12 at 18:47






  • 1




    You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
    – Peter Lawrey
    Nov 12 at 18:48










  • How should the code look like?
    – Foxal
    Nov 12 at 18:56








2




2




What is the expected result?
– GBlodgett
Nov 12 at 18:47




What is the expected result?
– GBlodgett
Nov 12 at 18:47




1




1




You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
– Peter Lawrey
Nov 12 at 18:48




You don't appear to need a loop for j. I would step through the code in your debugger until you get a line which doesn't do what you expect.
– Peter Lawrey
Nov 12 at 18:48












How should the code look like?
– Foxal
Nov 12 at 18:56




How should the code look like?
– Foxal
Nov 12 at 18:56












1 Answer
1






active

oldest

votes


















0














Is this result your expect?



Output :



in this word : BlackBerry there are at least two identical letters



in this word : Samsung sum of characters in the word > 255



in this word : Nokia sum of characters in the word > 255



in this word : Apple sum of characters in the word > 255



in this word : BlackBerry sum of characters in the word > 255



in this word : Alcatel sum of characters in the word > 255



in this word : Sony sum of characters in the word > 255



in this word : Jolla sum of characters in the word > 255



in this word : Nokia there is at least one character 'i'



in this word : BlackBerry there are at least two of the same characters



in this word : Alcatel there are at least two of the same characters



Code :



public static void main(String args) {
char tab = {
{'S', 'a', 'm', 's', 'u', 'n', 'g'},
{'N', 'o', 'k', 'i', 'a'},
{'A', 'p', 'p', 'l', 'e'},
{'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
{'A', 'l', 'c', 'a', 't', 'e', 'l'},
{'S', 'o', 'n', 'y'},
{'J', 'o', 'l', 'l', 'a'},
};

int letters;
int k = 0;
int licz = 0;

for (int i = 0; i < tab.length; i++) {
letters = 0;
for (int j = 0; j < tab[i].length-1; j++) {

k = j+1;

while (k < tab[i].length) {
if (tab[i][j] == tab[i][k])
letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");

for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);

System.out.print(" there are at least two identical letters");
System.out.println();
break;
}
}

}

System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
licz += (int) (tab[i][j]);
}
if (licz > 255) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" sum of characters in the word > 255");
System.out.println();
}

licz = 0;

}

letters = 0;
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
if (tab[i][j] == 'i')
letters++;
}
if (letters > 0) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there is at least one character 'i'");
System.out.println();
}

letters = 0;

}
System.out.println();
System.out.println();

for (int i = 0; i < tab.length; i++) {

for (int j = 0; j < tab[i].length-1; j++) {

k = j+1;
while (k < tab[i].length) {
if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32)
letters++;
k++;
}

if (letters == 2) {
System.out.print("in this word : ");
for (int l = 0; l < tab[i].length; l++)
System.out.print(tab[i][l]);
System.out.print(" there are at least two of the same characters");
System.out.println();
break;
}

}
letters = 0;
}
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268287%2fproblem-with-the-result-of-a-two-dimensional-array%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Is this result your expect?



    Output :



    in this word : BlackBerry there are at least two identical letters



    in this word : Samsung sum of characters in the word > 255



    in this word : Nokia sum of characters in the word > 255



    in this word : Apple sum of characters in the word > 255



    in this word : BlackBerry sum of characters in the word > 255



    in this word : Alcatel sum of characters in the word > 255



    in this word : Sony sum of characters in the word > 255



    in this word : Jolla sum of characters in the word > 255



    in this word : Nokia there is at least one character 'i'



    in this word : BlackBerry there are at least two of the same characters



    in this word : Alcatel there are at least two of the same characters



    Code :



    public static void main(String args) {
    char tab = {
    {'S', 'a', 'm', 's', 'u', 'n', 'g'},
    {'N', 'o', 'k', 'i', 'a'},
    {'A', 'p', 'p', 'l', 'e'},
    {'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
    {'A', 'l', 'c', 'a', 't', 'e', 'l'},
    {'S', 'o', 'n', 'y'},
    {'J', 'o', 'l', 'l', 'a'},
    };

    int letters;
    int k = 0;
    int licz = 0;

    for (int i = 0; i < tab.length; i++) {
    letters = 0;
    for (int j = 0; j < tab[i].length-1; j++) {

    k = j+1;

    while (k < tab[i].length) {
    if (tab[i][j] == tab[i][k])
    letters++;
    k++;
    }

    if (letters == 2) {
    System.out.print("in this word : ");

    for (int l = 0; l < tab[i].length; l++)
    System.out.print(tab[i][l]);

    System.out.print(" there are at least two identical letters");
    System.out.println();
    break;
    }
    }

    }

    System.out.println();
    System.out.println();

    for (int i = 0; i < tab.length; i++) {
    for (int j = 0; j < tab[i].length; j++) {
    licz += (int) (tab[i][j]);
    }
    if (licz > 255) {
    System.out.print("in this word : ");
    for (int l = 0; l < tab[i].length; l++)
    System.out.print(tab[i][l]);
    System.out.print(" sum of characters in the word > 255");
    System.out.println();
    }

    licz = 0;

    }

    letters = 0;
    System.out.println();
    System.out.println();

    for (int i = 0; i < tab.length; i++) {
    for (int j = 0; j < tab[i].length; j++) {
    if (tab[i][j] == 'i')
    letters++;
    }
    if (letters > 0) {
    System.out.print("in this word : ");
    for (int l = 0; l < tab[i].length; l++)
    System.out.print(tab[i][l]);
    System.out.print(" there is at least one character 'i'");
    System.out.println();
    }

    letters = 0;

    }
    System.out.println();
    System.out.println();

    for (int i = 0; i < tab.length; i++) {

    for (int j = 0; j < tab[i].length-1; j++) {

    k = j+1;
    while (k < tab[i].length) {
    if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32)
    letters++;
    k++;
    }

    if (letters == 2) {
    System.out.print("in this word : ");
    for (int l = 0; l < tab[i].length; l++)
    System.out.print(tab[i][l]);
    System.out.print(" there are at least two of the same characters");
    System.out.println();
    break;
    }

    }
    letters = 0;
    }
    }





    share|improve this answer




























      0














      Is this result your expect?



      Output :



      in this word : BlackBerry there are at least two identical letters



      in this word : Samsung sum of characters in the word > 255



      in this word : Nokia sum of characters in the word > 255



      in this word : Apple sum of characters in the word > 255



      in this word : BlackBerry sum of characters in the word > 255



      in this word : Alcatel sum of characters in the word > 255



      in this word : Sony sum of characters in the word > 255



      in this word : Jolla sum of characters in the word > 255



      in this word : Nokia there is at least one character 'i'



      in this word : BlackBerry there are at least two of the same characters



      in this word : Alcatel there are at least two of the same characters



      Code :



      public static void main(String args) {
      char tab = {
      {'S', 'a', 'm', 's', 'u', 'n', 'g'},
      {'N', 'o', 'k', 'i', 'a'},
      {'A', 'p', 'p', 'l', 'e'},
      {'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
      {'A', 'l', 'c', 'a', 't', 'e', 'l'},
      {'S', 'o', 'n', 'y'},
      {'J', 'o', 'l', 'l', 'a'},
      };

      int letters;
      int k = 0;
      int licz = 0;

      for (int i = 0; i < tab.length; i++) {
      letters = 0;
      for (int j = 0; j < tab[i].length-1; j++) {

      k = j+1;

      while (k < tab[i].length) {
      if (tab[i][j] == tab[i][k])
      letters++;
      k++;
      }

      if (letters == 2) {
      System.out.print("in this word : ");

      for (int l = 0; l < tab[i].length; l++)
      System.out.print(tab[i][l]);

      System.out.print(" there are at least two identical letters");
      System.out.println();
      break;
      }
      }

      }

      System.out.println();
      System.out.println();

      for (int i = 0; i < tab.length; i++) {
      for (int j = 0; j < tab[i].length; j++) {
      licz += (int) (tab[i][j]);
      }
      if (licz > 255) {
      System.out.print("in this word : ");
      for (int l = 0; l < tab[i].length; l++)
      System.out.print(tab[i][l]);
      System.out.print(" sum of characters in the word > 255");
      System.out.println();
      }

      licz = 0;

      }

      letters = 0;
      System.out.println();
      System.out.println();

      for (int i = 0; i < tab.length; i++) {
      for (int j = 0; j < tab[i].length; j++) {
      if (tab[i][j] == 'i')
      letters++;
      }
      if (letters > 0) {
      System.out.print("in this word : ");
      for (int l = 0; l < tab[i].length; l++)
      System.out.print(tab[i][l]);
      System.out.print(" there is at least one character 'i'");
      System.out.println();
      }

      letters = 0;

      }
      System.out.println();
      System.out.println();

      for (int i = 0; i < tab.length; i++) {

      for (int j = 0; j < tab[i].length-1; j++) {

      k = j+1;
      while (k < tab[i].length) {
      if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32)
      letters++;
      k++;
      }

      if (letters == 2) {
      System.out.print("in this word : ");
      for (int l = 0; l < tab[i].length; l++)
      System.out.print(tab[i][l]);
      System.out.print(" there are at least two of the same characters");
      System.out.println();
      break;
      }

      }
      letters = 0;
      }
      }





      share|improve this answer


























        0












        0








        0






        Is this result your expect?



        Output :



        in this word : BlackBerry there are at least two identical letters



        in this word : Samsung sum of characters in the word > 255



        in this word : Nokia sum of characters in the word > 255



        in this word : Apple sum of characters in the word > 255



        in this word : BlackBerry sum of characters in the word > 255



        in this word : Alcatel sum of characters in the word > 255



        in this word : Sony sum of characters in the word > 255



        in this word : Jolla sum of characters in the word > 255



        in this word : Nokia there is at least one character 'i'



        in this word : BlackBerry there are at least two of the same characters



        in this word : Alcatel there are at least two of the same characters



        Code :



        public static void main(String args) {
        char tab = {
        {'S', 'a', 'm', 's', 'u', 'n', 'g'},
        {'N', 'o', 'k', 'i', 'a'},
        {'A', 'p', 'p', 'l', 'e'},
        {'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
        {'A', 'l', 'c', 'a', 't', 'e', 'l'},
        {'S', 'o', 'n', 'y'},
        {'J', 'o', 'l', 'l', 'a'},
        };

        int letters;
        int k = 0;
        int licz = 0;

        for (int i = 0; i < tab.length; i++) {
        letters = 0;
        for (int j = 0; j < tab[i].length-1; j++) {

        k = j+1;

        while (k < tab[i].length) {
        if (tab[i][j] == tab[i][k])
        letters++;
        k++;
        }

        if (letters == 2) {
        System.out.print("in this word : ");

        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);

        System.out.print(" there are at least two identical letters");
        System.out.println();
        break;
        }
        }

        }

        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {
        for (int j = 0; j < tab[i].length; j++) {
        licz += (int) (tab[i][j]);
        }
        if (licz > 255) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" sum of characters in the word > 255");
        System.out.println();
        }

        licz = 0;

        }

        letters = 0;
        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {
        for (int j = 0; j < tab[i].length; j++) {
        if (tab[i][j] == 'i')
        letters++;
        }
        if (letters > 0) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" there is at least one character 'i'");
        System.out.println();
        }

        letters = 0;

        }
        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {

        for (int j = 0; j < tab[i].length-1; j++) {

        k = j+1;
        while (k < tab[i].length) {
        if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32)
        letters++;
        k++;
        }

        if (letters == 2) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" there are at least two of the same characters");
        System.out.println();
        break;
        }

        }
        letters = 0;
        }
        }





        share|improve this answer














        Is this result your expect?



        Output :



        in this word : BlackBerry there are at least two identical letters



        in this word : Samsung sum of characters in the word > 255



        in this word : Nokia sum of characters in the word > 255



        in this word : Apple sum of characters in the word > 255



        in this word : BlackBerry sum of characters in the word > 255



        in this word : Alcatel sum of characters in the word > 255



        in this word : Sony sum of characters in the word > 255



        in this word : Jolla sum of characters in the word > 255



        in this word : Nokia there is at least one character 'i'



        in this word : BlackBerry there are at least two of the same characters



        in this word : Alcatel there are at least two of the same characters



        Code :



        public static void main(String args) {
        char tab = {
        {'S', 'a', 'm', 's', 'u', 'n', 'g'},
        {'N', 'o', 'k', 'i', 'a'},
        {'A', 'p', 'p', 'l', 'e'},
        {'B', 'l', 'a', 'c', 'k', 'B', 'e', 'r', 'r', 'y'},
        {'A', 'l', 'c', 'a', 't', 'e', 'l'},
        {'S', 'o', 'n', 'y'},
        {'J', 'o', 'l', 'l', 'a'},
        };

        int letters;
        int k = 0;
        int licz = 0;

        for (int i = 0; i < tab.length; i++) {
        letters = 0;
        for (int j = 0; j < tab[i].length-1; j++) {

        k = j+1;

        while (k < tab[i].length) {
        if (tab[i][j] == tab[i][k])
        letters++;
        k++;
        }

        if (letters == 2) {
        System.out.print("in this word : ");

        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);

        System.out.print(" there are at least two identical letters");
        System.out.println();
        break;
        }
        }

        }

        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {
        for (int j = 0; j < tab[i].length; j++) {
        licz += (int) (tab[i][j]);
        }
        if (licz > 255) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" sum of characters in the word > 255");
        System.out.println();
        }

        licz = 0;

        }

        letters = 0;
        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {
        for (int j = 0; j < tab[i].length; j++) {
        if (tab[i][j] == 'i')
        letters++;
        }
        if (letters > 0) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" there is at least one character 'i'");
        System.out.println();
        }

        letters = 0;

        }
        System.out.println();
        System.out.println();

        for (int i = 0; i < tab.length; i++) {

        for (int j = 0; j < tab[i].length-1; j++) {

        k = j+1;
        while (k < tab[i].length) {
        if ((int) (tab[i][j]) == (int) (tab[i][k]) || (int) (tab[i][j]) == (int) (tab[i][k]) - 32)
        letters++;
        k++;
        }

        if (letters == 2) {
        System.out.print("in this word : ");
        for (int l = 0; l < tab[i].length; l++)
        System.out.print(tab[i][l]);
        System.out.print(" there are at least two of the same characters");
        System.out.println();
        break;
        }

        }
        letters = 0;
        }
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 at 9:44

























        answered Nov 16 at 8:05









        ishi ya

        11




        11






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268287%2fproblem-with-the-result-of-a-two-dimensional-array%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine