Posts by Math • 30,313 points
252 posts
-
4
votes3
answers3518
viewsA: How to solve the problem "The main method was not found" in a Java class?
This code can go anywhere within your class, for example like this: import java.util.List; import java.util.ArrayList; import java.util.Collections; public class Declaracao_Array { public static…
-
6
votes2
answers631
viewsA: Problem with Arraylist
You imported the wrong package: import java.awt.List; When it was meant to be: import java.util.List; As can be seen in the documentation List that you used does not make use of the generics, while…
-
1
votes1
answer1403
viewsA: Add item to Arraylist every time an object is instantiated
It depends a lot on your modeling, you first of all have to decide that it will belong to who, and what it makes sense to be created without being associated with someone. Example: Is it possible to…
-
4
votes1
answer236
viewsA: Conditionals and Control Flow (Codecademy Python 9/15)
Your mistake is in the second item, which is this: Match bool_two to False and not True or True result Running the code: print False and not True or True You will get as a result: True Looking at…
-
11
votes3
answers115
viewsA: Is there any way to generalize library imports into Java?
It’s possible, just do: import Banco.* That will import all the package class Banco. Note however that according to Javabeans, packages should have the first minuscule letter, which is precisely to…
-
48
votes3
answers21968
viewsA: What is the purpose of the Serializable interface?
Serialization means saving the current state of the objects in binary format to your computer, so this state can be recovered later by recreating the object in memory just as it was at the time of…
-
7
votes1
answer715
viewsA: Java data input and output and data processing
For question 39, you had only minor errors in your code, see the comments in the code itself: import java.util.Scanner; import java.io.File; import java.io.PrintWriter; import…
-
9
votes2
answers2368
viewsA: How to use "Biginteger" type to solve this problem?
That method is not 100% necessary, you can use the Biginteger type instead of the int, the difference is that Biginteger is a class and its objects are immutable, and its methods return a value,…
-
1
votes2
answers332
viewsA: What is the behavior of the reference variable and the primitive variable?
Is not possible nay initialize a primitive variable. See the test: public class Teste { static int iInstancia; //inicializada automaticamente, com 0 static Integer objInstancia; //não-inicializada…
-
1
votes2
answers68
viewsA: Is it necessary to place the element type inside the Try?
It is necessary to place the element type inside the Try? Yes. But there’s more to fix in your code. On that line there are two problems: try(stmt = getConnection().prepareStatement(sql)){} What you…
-
5
votes1
answer1716
viewsA: Values within a given range
It is not possible to combine two comparison operators in the test of a condition, to do this it is necessary to use the function E(). =SE(E(A1<=B1;B1>=C1);1;0)…
-
14
votes3
answers13058
viewsA: How to do a range with letters of the alphabet in python?
import string a = list(string.ascii_lowercase) print a Upshot: ['a', 'b', 'c', ’d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', ’m', 'n', 'o', 'p', 'q', 'r', ’s', t', 'u', 'v', 'w', 'x', 'y', 'z']…
-
5
votes3
answers25171
viewsA: How to write multiple lines in Python?
To make a string has multiple lines you can use the line break character \n. Thus: string = 'uma linha\noutra linha' print string You can still use the function os.linesep which according to the…
-
8
votes2
answers15912
viewsA: How do I join a list in Python?
You can use the extend(). Example: a = [1, 2, 3] b = [4, 5, 6] a.extend(b) print a Upshot: [1, 2, 3, 4, 5, 6] More information about list methods: Pythons Docs - Data Structures…
-
29
votes3
answers7920
viewsA: What is the difference between "git init" and "git init --Bare"?
With the command git init --bare you are creating a repository that is pushable. Generally the repositories bare are created on the server and are considered repositories for storage, in contrast to…
-
3
votes1
answer878
viewsA: Python functions
Your problem is on the lines: cube(number) print "resultado = %d" % number That you call the function cube() passing the number, but you forget to do your job by_three() return something, as it does…
-
6
votes1
answer488
viewsA: How to make my own commands and shortcuts in Eclipse?
The name of this is "Code Template", to create a go in Windows Prefences Java Editor Templates, to get to the following screen: Click "New" to create your template code. As an example, I created a…
-
0
votes3
answers6122
viewsA: Where can I find the Windowbuilder package for download/installation in the Eclipse IDE?
The Mars version of Eclipse already comes with Windowbuilder installed, so just download the package intended for Javase on the site of Eclipse itself, the link: http://eclipse.org/downloads Choose…
-
10
votes2
answers21680
viewsA: Redeem the largest number of a matrix with criteria
Use the "MAXIMUM" function and within it use the "SE". However, you should be aware that the formula thus works for a single cell, for your case it is necessary to make it work with vectors, and for…
-
7
votes3
answers2023
viewsA: Is there a nomenclature standard for enums?
The standard of nomenclature of enums follows the same standard of class nomenclature, for the simple fact of enum be a special kind of class. Therefore, give your name in a way representative of…
-
8
votes4
answers13756
viewsA: Sort List in java
Can implement the Comparable interface and make objects of the person class comparable to other objects of the same type: import java.util.ArrayList; import java.util.Collections; import…
-
1
votes1
answer797
viewsA: Add event (action) when switching tab
You can add a Switch for each tab, with the code below: tabPane.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void…
-
7
votes1
answer12788
viewsA: Rounding of hours (every 30 minutes)
Use the function MARRED (or MROUND if your Office is in English). It returns a number rounded to the desired multiple. To use with schedules, do so: =MARRED(A2;"0:30") To always round down, do so:…
-
8
votes2
answers7676
viewsA: How to add SQL Server dependency to Maven?
This artifact is not loaded in the online Maven repositories. The solution is to download the microsoft website and manually add it to your local Maven repository with the command: mvn…
-
29
votes5
answers409
viewsA: Today (06/30/2015) we will have a second more, what could be the consequences for our systems?
Getting around the problem Watches do not normally account for the second of number 60, so some alternatives should be taken in this regard. Some possibilities are: Some Linux kernels implement a…
-
12
votes1
answer7264
viewsA: Take values separated by spaces in Java
You can separate using the method split() string class: public class SplitString { public static void main(String[] args) { String valores = "1 2 3"; String[] arrayValores = valores.split(" "); for…
-
9
votes3
answers191
viewsA: Has the standard Java output function accepted several parameters?
Maybe your teacher is confusing the println() with the printf(), because something similar to what you want can be done like this: public class Teste { public static void main(String[] args) { int…
-
3
votes1
answer1815
viewsA: How to assemble GPS bar code numbers?
Barcodes follow patterns, some of them are: Code 39 Code 128 EAN 8 EAN 13 EAN 128 Codabar First you should know if for your application in question there is no convention that defines which is the…
-
30
votes1
answer4521
viewsA: Differences between <T> and <?>
The T in <T> is a placeholder of the type it will represent for a certain variable within a class. It is used in class declaration and its methods. Example: class MeuGenerico<T> { //T…
-
12
votes3
answers22761
viewsA: Compile C in Sublime Text
Download the Mingw (GCC ported to Windows) on that website, install it and add the system variables. Click on Tools > Build System > New Build System, in the window that opens put the code…
-
3
votes1
answer1376
viewsA: Dividing integers in MS Excel (exact division)
You can use the formula =ARREDONDAR.PARA.BAIXO(A2/B2;0) to calculate the whole number, and the quantity in the OP with the rest would be according to the formula =A2-B2*C2. Thus: Then you can play…
-
1
votes1
answer265
viewsA: How to place a Mousecliked event on a table using Javafx
Your method should be as follows: @FXML public void tblArquivosMouseCliked(MouseEvent event) { System.out.println("Click Detectado"); }
-
8
votes4
answers15572
viewsA: What is the super() function for;
The super() serves to call the superclass builder. It is always called, even when it is not explicit in the code, when it is explicit it must be the first item within the constructor. See for…
-
4
votes2
answers103
viewsA: Doubt in inheritance
You are correct in saying that your code should call the method that returns new B(), but in fact, that’s what it does. See below: public class CovariantTest { public static void main(String[]…
-
4
votes1
answer808
viewsA: Randomization in Memory Game
Your code compiles and fills the Jbuttons with random numbers, that is to say that little is missing to achieve your goal, basically what is missing is to put an image in the place of a number. A…
-
1
votes1
answer1231
viewsA: Jar does not execute.
As you say you already have the MANIFEST.MF file inside the META-INF folder, what you lack now is to indicate in that file the full address of your main class, so: Main-Class: com.pacote.Classe In…
-
8
votes2
answers6790
viewsA: Can an int equal null?
As well said in @pmargreff’s reply, int under no circumstances will it be null. But what if the type variable int is not initialized, with what value it turns out? It depends, if the variable…
-
5
votes3
answers917
viewsA: Formatting String with Dateformat using a Timezone is not working
The converter you are using is not considering the time in milliseconds, but in seconds. Using the value 1432313391 in this other converter the output for your input gives the same result as the…
-
1
votes2
answers2182
viewsA: Repeated elements in a matrix
To traverse an array you need a for within a for, So a possible solution is to go through the matrix and compare each element by going through the matrix again. So you’ll have 4 fornested s, the…
-
2
votes2
answers1113
viewsA: How to retrieve specific parts/values/os from a string?
You can use the substring() to take only the part of the text that interests you. If the number you want to pick is always after codcal= and for the last part of your string, you can do so: public…
-
10
votes2
answers4016
views -
3
votes1
answer4413
viewsA: How do I change a java desktop application icon in Eclipse?
The problem with being able to change the icon is why your Java Desktop application generates a .jar, and unlike files with extension .exe the .jar does not have its own icon, its icon is the same…
-
2
votes1
answer382
viewsA: Somatório Multithead
The problem is in the following code snippet: public void run(){ for(int i = inicio; i < i + qtd;i++){ soma += a[i]; } } You must do: public void run(){ for(int i = inicio; i < inicio +…
-
11
votes8
answers17275
viewsA: Difference between while and for
There is a way to show that one is better than the other? Usually the while is used while a certain condition is not met. Example: boolean continua = true; while(continua) { //alguma lógica...…
-
29
votes4
answers19183
viewsA: Is it possible to comment on a JSON file?
No. Unable to comment on JSON.
-
36
votes1
answer39248
viewsA: How do I undo a "git add" before a commit?
To undo the inclusion of an item do: git reset <nomearquivo> If you did git add ., can undo the inclusion of all files at once by doing: git reset…
-
10
votes1
answer234
viewsA: Encapsulation and Java Access Modifiers
It depends a lot on what your method fazQualquerCoisa() and how the getter of your String, if inside the getter he only has one return nome; so whatever, if there is any specific treatment of your…
-
19
votes2
answers14617
viewsA: What is the difference and what are operators & and && e | and || in Java for?
The difference between the logical operators that use a symbol and two symbols is that when you use two is what is known as logic short circuit operators. The logic short-circuit operator performs…
-
19
votes2
answers574
viewsA: Is it possible to have month 13 on a date in Java?
Looking further down, the documentation you linked has the same repeated snippet, only this time with a more detailed explanation, and it says: Month, Formatted as two digits with Leading zeros as…
-
2
votes1
answer889
viewsA: Insert values from an array of bytes into an int array without converting them
As far as I know, there is no ready-made Java function that allows you to do this in a row, perhaps because it is something relatively simple. Just in case, I went to confirm Jon Skeet spoke on the…