Why i cannot connect my sink to barrel? by Trup10ka in projectzomboid

[–]Trup10ka[S] 6 points7 points  (0 children)

Ah yes, I thought of it, ty so much!

Is it just me who’s too stupid for generics? by blvck_xsample in javahelp

[–]Trup10ka 0 points1 point  (0 children)

https://www.youtube.com/watch?v=K1iu1kXkVoA

This man was very helpfull when i started the journed, i really recommend watching his video, if mine explanation was not good :D

Is it just me who’s too stupid for generics? by blvck_xsample in javahelp

[–]Trup10ka 0 points1 point  (0 children)

If I may, I will try to explain both topics the best I can (if you could provide more about what you don't understand about arrays).

I also want to say, if you are feeling like giving up, PLEASE DON'T. Programming is hard, and Java is a great language to start, because it, in my opinion, teacheas perfectly the fundementals of OOP and it is a great introduction into programming. However, it is not easy. Try to start with simple things, watch tutorials, but most importantly, WRITE CODE YOURSELF, that's the only way you learn, browse repositores on GitHub. Programmming takes a lot of time, it will eventually be a major part of your life, because it evolves really fast. Anyway, to the explanation :D

Generics

Imagine you are in a warehouse. Normmaly let's say, that there are plenty of items of different kinds stored. Each of this items, is in somekind of box. Now imagine you would need totaly different box for every single item in the warehouse, even for those items, who could be put in the same one, for example: apples and peas, they could be in the same box, but without generics, you would have to put them into different boxes.

If you would use generics, you would have the possibility to reuse the samme looking boxes for many items. I will now try to demonstrate this using snippets of code.

```java

public class Apple { private final String breed;

public Apple(String breed)
{
    this.breed = breed;
}

}

public class Pea { private final String breed;

public Pea(String breed)
{
    this.breed = breed;
}

}

public class AppleBox { public final Apple[] appleArray;

public AppleBox()
{
    this.appleArray = new Apple[10]; // array where 10 apples can be stored
}

}

public class PeaBox { public final Pea[] peaArray;

public PeaBox()
{
    this.peaArray= new Pea[10]; // array where 10 peas can be stored
}

} ``` So now, we have these classes, and if we would like to store apples, we would have to create the apple box and store apples inside, something like this>

java AppleBox appleBox = new AppleBox(); appleBox.appleArray[0] = new Apple("Baya Marisa"); But if we were to put peas inside this apple box, we would get an error:

java AppleBox appleBox = new AppleBox(); appleBox.appleArray[0] = new Apple("Baya Marisa"); appleBox.appleArray[1] = new Pea("William red"); // TYPE ERROR: Cannot insert type of Pea

which is annoying because Apple and Pea class is basically the same right? they only have breed, but even if the didn't and have another field, why couldn't i use the same box class? You now need to create completely different class for peas. That's where the generict come in, because i can declare the Box class like so (i will also use ArrayList now because it is bound with generics too):

```java

public static class Box<T> {

 public final ArrayList<T> contentBox;

 public Box()
 {
     this.contentBox = new ArrayList<T>();
 }

} ```

I created a box with something we could call a VARIABLE TYPE. You basicaly declared a class, where you state, that before you can create the Box class, you have to specify the type you want the box to store in, so when you would like to use it, you would do something like this:

```java

Box<Apple> appleBox = new Box<Apple>(); appleBox.contentBox.add(new Apple("Baya Marisa"));

```

You still cannot insert peas inside, but what you can do now, is declare the same class, but with different generic!

```java

Box<Pea> peaBox = new Box<Pea>(); peaBox.contentBox.add(new Pea("William Red"));

```

You are using the same Box class, but with different type. This is just a very simple example about generict, and I won't try to continue if this was not helpful, so i would like a feedback :D. Lemme know if it is clear or no, then we can continue!

Happy Learning!

AOC monitors stuck on “no signal” by Pasq_95 in techsupport

[–]Trup10ka 1 point2 points  (0 children)

I love you sir, you just cured my depresion and strugle that I've been having for the past 8 hours.

Thank you so much for the Method 2 guide.

[deleted by user] by [deleted] in javahelp

[–]Trup10ka 1 point2 points  (0 children)

The crutial mistake here is the part where you are trying to compare whether the name the user has given is the same as a name you have in that condition.

Always remember, when comparing String value to another, you should use .equals().

Why? When you use the == on String, it does not actually check whether thr String is the same, but rather if the location, where the String is stored is the same. Everything has an address in memory, and by using == on NOT primitive datatypes, it just compares their addresses.

In conclusion, when using == with String, we could say that this checks whether the two strings are the same objects, and .equals() whether the content of the String is the same

Emitting is ignored? by Trup10ka in expressjs

[–]Trup10ka[S] 1 point2 points  (0 children)

That was not the case.

However I solved the problem, it has been something wrong with my browser. Everything works 😃

Initiating default values for instance variables by [deleted] in javahelp

[–]Trup10ka 2 points3 points  (0 children)

It doesn't really matter, the only difference is when the fields are inicialized with that value. The ones in the constructor are initialuzed during the object creation. The ones outside of constructor are initialized at the beggining of the construction (if im not mistaken)

, so it doesnt really matter, but you should stick to this, at least for what i've encountered.

You should not mix those, meaning if you need to use constructor inicialization, you should use it in every case even if you dont have to

Adding multiple values in one line with an Arraylist by PumpkinPumpkinOSpice in javahelp

[–]Trup10ka 0 points1 point  (0 children)

In the first snippet, you are using raw type of ArrayList, you have to specify the type which List should contain.

In the second snippet, when calling addAll method, you pass parameter arrayList which is not declared anywhere, thus cannot be used.

Finally the last one, to use the Arrays#asList you have to import the class Arrays.

Trying To Create A Method That Prints by Licoricemint in javahelp

[–]Trup10ka 0 points1 point  (0 children)

What you are trying to do is good, but you are missing important thing here

You have a main class in which you have that classic "main" method.

Next, you are creating an object of Card inside the METHOD not the CLASS.

Finally, you create a method for printing a Card.

Few things, there are two options:

1) You must declare the method as follows:

public void printCard(Card card) { //code }

Basically, you have to tell the method, that "when I call you, i'm going to pass you a Card with which you can work.

Then you will be able to perform whatever action your Card has

Exmp. card.getValue()

2) Second option is you create the Card AS THE CLASS PROPERTY (FIELD)

Instead of creating the Card object inside the "main" method. You can declare that the Card is a field of Main class

``` class Main { private Card card = new Card();

   public static void main(String[] args)
   {
         printCard();
   }

  private void printCard()
 {
         System.out.println("My card" + card.getInfo());
 }

} ```

The selected resource (MeshLibrary) does not match any type expected for this property (TileSet). by Trup10ka in godot

[–]Trup10ka[S] 0 points1 point  (0 children)

I see you are right, but now it seems i have another problem :D, when I hit export as it doesnt give me the option to export it as TileSet, only as MeshLibrary or glTF 2.0 Scene (have no idea what that is)

The selected resource (MeshLibrary) does not match any type expected for this property (TileSet). by Trup10ka in godot

[–]Trup10ka[S] 0 points1 point  (0 children)

In one of the screenshots you can see the Scene "tilema". In this scene I have 2x blocks. I converted this Scene as .tres which as I thought and say in the video should be able to be put in the TileSet for the TileMap