Forums - Open Redstone Engineers
Question about my java program (Sorry xeo D:) - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: Question about my java program (Sorry xeo D:) (/thread-494.html)



Question about my java program (Sorry xeo D:) - David - 07-03-2013

Hello I am kinda new to java, I've been messing around with it a lil for the past few weeks.

Now I created this program that would print out a 5x5 square using an 2d String array.

Here is my code:

Code:
package main;

public class Main {
    
    //Creating an 2D array of strings.
    
    public static String[][] screen = new String[5][5];
    
    public static void main(String[] args) {
        
        //Setting the array using some fancy for loops.
        
        for(int i = 0; i < 5; i++)
            for(int j = 0; j < 5; j++)
                screen[i][j] = j + ", " + i;
        
        //Printing the array using some fancy for loops.
        for(int i = 0; i < 5; i++)
        {
            for(int j = 0; j < 5; j++)
            {
                if(j == 4)
                {
                    System.out.println("");
                }
                else
                {
                    System.out.print(screen[i][j] + " | ");
                }
            }
        }
    }
}

The problem is that I'm getting this output:
Code:
0, 0 | 1, 0 | 2, 0 | 3, 0 |
0, 1 | 1, 1 | 2, 1 | 3, 1 |
0, 2 | 1, 2 | 2, 2 | 3, 2 |
0, 3 | 1, 3 | 2, 3 | 3, 3 |
0, 4 | 1, 4 | 2, 4 | 3, 4 |

Which is a 4x5 square and not a 5x5 one. Can someone tell me what the problem is?

(Xeo, please do not say that the problem is java itself Tongue)


RE: Question about my java program (Sorry xeo D:) - qwerasd205 - 07-03-2013

I would try using
Code:
public static String[][] screen = new String[6][5];
i think that it is messed up slightly in JAVA so that X goes -1


RE: Question about my java program (Sorry xeo D:) - David - 07-03-2013

(07-03-2013, 07:33 PM)qwerasd205 Wrote: I would try using
Code:
public static String[][] screen = new String[6][5];
i think that it is messed up slightly in JAVA so that X goes -1

OK, got it working! Ty.


RE: Question about my java program (Sorry xeo D:) - Xeomorpher - 07-03-2013

Now. Burn java.


RE: Question about my java program (Sorry xeo D:) - David - 07-03-2013

(07-03-2013, 07:38 PM)Xeomorpher Wrote: Now. Burn java.

I'm wondering xeo, how many angry e-mails have you sent to oracle? Be honest.


RE: Question about my java program (Sorry xeo D:) - VirtualPineapple - 07-03-2013

David, why Java ;n;


RE: Question about my java program (Sorry xeo D:) - David - 07-03-2013

(07-03-2013, 07:50 PM)VirtualPineapple Wrote: David, why Java ;n;

I'm *kinda* new to programming, besides batch (Which isn't really a programming language) I don't know any language, and Java is an easier to learn language (I think). So I will be movin' to C or C++ or something


RE: Question about my java program (Sorry xeo D:) - seankingman - 07-03-2013

You should try BASIC; or if you want a starter launguage, try Python.


RE: Question about my java program (Sorry xeo D:) - David - 07-03-2013

(07-03-2013, 08:22 PM)seankingman Wrote: You should try BASIC; or if you want a starter launguage, try Python.

I know a tiny, tiny, TINY bit of basic. Pyton , naaah. Isnt that a scripting language?


RE: Question about my java program (Sorry xeo D:) - seankingman - 07-03-2013

I also only know a tiny bit of BASIC and a little bit of VB and C++. As for Python, consult Xeo.


RE: Question about my java program (Sorry xeo D:) - qwerasd205 - 07-03-2013

(07-03-2013, 08:37 PM)David Wrote:
(07-03-2013, 08:22 PM)seankingman Wrote: You should try BASIC; or if you want a starter launguage, try Python.

I know a tiny, tiny, TINY bit of basic. Pyton , naaah. Isnt that a scripting language?
Yes, it is a scripting language, do you want a coding language?


RE: Question about my java program (Sorry xeo D:) - David - 07-04-2013

(07-03-2013, 09:10 PM)qwerasd205 Wrote:
(07-03-2013, 08:37 PM)David Wrote:
(07-03-2013, 08:22 PM)seankingman Wrote: You should try BASIC; or if you want a starter launguage, try Python.

I know a tiny, tiny, TINY bit of basic. Pyton , naaah. Isnt that a scripting language?
Yes, it is a scripting language, do you want a coding language?

Yeh, like java or C


RE: Question about my java program (Sorry xeo D:) - VirtualPineapple - 07-04-2013

I don't see what your problem is with Python...


RE: Question about my java program (Sorry xeo D:) - David - 07-04-2013

(07-04-2013, 10:13 AM)VirtualPineapple Wrote: I don't see what your problem is with Python...

I don't have a problem with python, but I just don't feel like learning it because I already know a scripting language (batch). So I feel like thats, naah.


RE: Question about my java program (Sorry xeo D:) - qwerasd205 - 07-04-2013

(07-04-2013, 02:21 PM)David Wrote:
(07-04-2013, 10:13 AM)VirtualPineapple Wrote: I don't see what your problem is with Python...

I don't have a problem with python, but I just don't feel like learning it because I already know a scripting language (batch). So I feel like thats, naah.
I understand, I don't really want to code per say, that's why i learned languages such as Perl Python and Lua.


RE: Question about my java program (Sorry xeo D:) - Chibill - 07-04-2013

Python is a coding langue to you can compile them to runables in py2exe or if you use jython by putting then in the jar and doing alitle rename ing.


RE: Question about my java program (Sorry xeo D:) - Xeomorpher - 07-04-2013

... That doesn't change the language, nor it's purpose.

Python is one of the most flexible langs I have played with, I often use it for scripting tasks, but it's main merit, is that I can write code in it so damn fast, which allows it to make our plugins: Super fast, and everyone can read everyone's code (apart from jer)


RE: Question about my java program (Sorry xeo D:) - fl3tching101 - 07-05-2013

As to Python yes, great language, but a little TOO easy for beginners, kinda teaches bad habits in my book. As to Java being an easy language to begin with, wash your fingers off with soap. I don't care what the interwebs say about it being easy, THEY LIE. Code in C++, script in Python. Simple answer, short, sweet, to the point, and that's not common cause I like to ramble but it be late. Happy coding/scripting!


RE: Question about my java program (Sorry xeo D:) - VirtualPineapple - 07-05-2013

"As to Java being an easy language to begin with, wash your fingers off with soap" But me palms are dirty too D:


RE: Question about my java program (Sorry xeo D:) - David - 07-07-2013

C++ is not short Tongue You gotta include EVERYTHING litteraly EVERYTHING.


RE: Question about my java program (Sorry xeo D:) - VirtualPineapple - 07-07-2013

Not really...


RE: Question about my java program (Sorry xeo D:) - David - 07-08-2013

(07-07-2013, 10:23 PM)VirtualPineapple Wrote: Not really...

unless you use something like std:Confusedomething


RE: Question about my java program (Sorry xeo D:) - JeremyG - 07-08-2013

"using namespace std;"


RE: Question about my java program (Sorry xeo D:) - David - 07-10-2013

(07-08-2013, 02:39 PM)JeremyG Wrote: "using namespace std;"

ik but that thing I posted earlier also works


RE: Question about my java program (Sorry xeo D:) - seankingman - 07-11-2013

I've just started getting into Java and it's actually quite fun. I made and modified Benny's Pong game, adding multiplayer support and a 'first to five' game objective.
I'm having trouble compiling it with NetBeans though.


RE: Question about my java program (Sorry xeo D:) - Chibill - 07-15-2013

Use eclipse it's easyer and can compile it on save in to your bin file,


RE: Question about my java program (Sorry xeo D:) - qwerasd205 - 07-18-2013

(07-15-2013, 04:20 AM)Chibill Wrote: Use eclipse it's easyer and can compile it on save in to your bin file,

(07-15-2013, 04:20 AM)Grammar Nazi Wrote: Use eclipse,'*' it's easier'*' and can compile it 'on save' into'*' your bin file.'*'



RE: Question about my java program (Sorry xeo D:) - Xeomorpher - 07-18-2013

xD; You're worse than me.


RE: Question about my java program (Sorry xeo D:) - Xeomorpher - 07-18-2013

also, ideally, 'Use eclipse;* it's easier, and it* can compile on save into your bin file.' is better.


RE: Question about my java program (Sorry xeo D:) - qwerasd205 - 07-18-2013

(07-18-2013, 09:28 PM)Xeomorpher Wrote: also, ideally, 'Use eclipse;* it's easier, and it* can compile on save into your bin file.' is better.

(07-18-2013, 09:28 PM)Grammar Nazi Wrote: ->'A' lso, ideally, 'Use eclipse ";" <(The next statements are not independent; They are reasons. The , was correct.) (if you used a semicolon then CAPITALIZE!) 'I' t's easier, and "it" <(Unnecessary to verify the subject.) can compile on save into your bin file." ' " <( , ) is better.



RE: Question about my java program (Sorry xeo D:) - TheGeek56 - 09-28-2013

Burn F# ;-;


RE: Question about my java program (Sorry xeo D:) - Xray_Doc - 09-29-2013

So I just started learning code for Java (Using Eclipse in school) and I can understand about 1/4 of this stuff.


RE: Question about my java program (Sorry xeo D:) - VirtualPineapple - 09-29-2013

I are great dissapoint in you xcray


RE: Question about my java program (Sorry xeo D:) - Xray_Doc - 09-30-2013

Hey, take it easy. I just learned class, task, and other basic functions.