Posts by igventurelli • 4,441 points
166 posts
-
0
votes1
answer44
viewsA: I do 2 dates check plus is persisting
The problem is here: try { if (servico.getDiaServico().after(servico.getDiaGarantia())) { FacesUtil.addWarnMessage("A data do serviço, não pode ser maior do que a data da garantia."); }…
-
3
votes3
answers4536
viewsA: How to select a piece of the Java string?
You can use the methods indexOf() and substring() both of the class String: public class Teste { public static void main(String[] args) { String x = "@646646&"; int indexArroba = x.indexOf("@");…
-
1
votes1
answer578
viewsA: How do I boost code on android?
You can use the static method pow(dobule val1, double val2) class Math: System.out.println(Math.pow(2.0, 3.0)); //2 elevado a 3 Exit: 8.0…
-
3
votes2
answers3476
viewsA: Get the first letter of the last name and last name?
To get the first letter of the last name you can use the method lastIndexOf() class String: String nome = "Carlos Eduardo Martins Dutra do Rego"; int posicaoUltimoEspaco = nome.lastIndexOf(" ");…
javaanswered igventurelli 4,441 -
13
votes2
answers7914
viewsA: What is the difference between Java Keywords extends and Java Implements?
extends Is used extends when you want to apply inheritance to your class. When we say the class A stretches the class B, means that A inherits some (or all) class methods and attributes B. The only…
-
2
votes1
answer116
viewsQ: list.clear() vs list = new Arraylist<T>()
To remove all items from a list, I can do it in two ways: lista.clear() and lista = new ArrayList<T>(). What are the differences between them? In which situations should I use each one?…
-
0
votes2
answers441
viewsA: How to disable double-click the header of a Datagrid?
I believe it is not possible to disable. Alternatively you can skip douplo by clicking the header: private void grid_MouseDoubleClick(object sender, MouseButtonEventArgs e) {…
-
1
votes2
answers86
viewsQ: Capture list item by index
I have the code: for(int i = 0; i < 99999; i++) { minhaLista.get(i + x); //x é int e possui um valor qualquer } At some point the sum of i + x results in a value greater than the list size. If…
-
3
votes2
answers73
viewsA: With editing Tabcontrol in c#?
If you don’t want the tabs to appear, you’re probably using the wrong component. The TabControl serves exactly to provide tabs. Instead of TabControl, consider using a Panel. You can find the class…
c#answered igventurelli 4,441 -
0
votes2
answers54
viewsA: Mounts a vector with 5 students, in the fifth student this vector multiplies by 2, being able to give input to 10
Expanding array size is impossible. What you can do is reassign the variable alunos with a new larger dimension array based on old values through the method copyOf() class java.util.Arrays: public…
javaanswered igventurelli 4,441 -
0
votes2
answers192
viewsA: Log in with Asp.net 4.5 (Entity Framework)?
You can use the method Any() of LINQ. It returns true if there is any (any in English) record. If it does not exist returns false. Ex: if(contexto.Entidade.Any(x => x.Login == txtLogin.Text…
-
2
votes1
answer443
viewsA: Print a Java Object List
You need to "type" the foreach: List<CursoTurno> cursoId = cursoTurnoRepository.findByTurnoId(idTurno); for(CursoTurno c : cursoId) { }
-
1
votes2
answers727
viewsA: How to rescue the App.config connection string from another project?
Add reference System.Configuration in your project and make: string conexao = System.Configuration.ConfigurationManager. ConnectionStrings["ConexaoTeste2"].ConnectionString; About the fact that the…
-
2
votes1
answer166
viewsQ: When will the object be eligible for the Garbagecollector?
From the code snippets below, in which the object created in new Pessoa("João") will be available for the Garbage Collector on the line: //outras instruções ? They are all independent codes. They…
-
1
votes2
answers837
viewsA: How to implement a class to use Preparedstatement through it?
You can do it like this: public static void main(String[] args) { try { Conecta c = new Conecta(); String nomeCraque = "Coca"; String sql = "insert into produto (nome) values (?)"; //Cria um…
-
2
votes1
answer1103
viewsA: What is the difference between Error and Exception?
Based in that SO gringo response: Errorare very big problems that should not be dealt with or launched. They are problems that when they happen, there is not much to do. Already Exceptions can be…
-
1
votes1
answer1103
viewsQ: What is the difference between Error and Exception?
Why we have Exceptions (IOException, for example) and Errors (OutOfMemoryError, for example)? I know you both inherit from the class Throwable, but what’s the difference between them?…
-
3
votes2
answers2427
viewsA: Exclude element from an array
Need to delete the first element of an array It is not possible to exclude a position or element from an array. If the array has 10 positions, it will always have 10 positions. Use the method…
-
14
votes4
answers4422
viewsA: What is the difference between & and &&operators?
there is some difference between using one and the other? Yes. Compare with two & means to make Circuit short. Ex: if((condicao1) & (condicao2)) { } In doing so, Runtime will check the two…
-
2
votes3
answers1224
viewsA: C# - Close Form without Stopping Application
You can change from .Show() for .ShowDialog() and close your form when the second form is disposed: if (usuarioTextBox.Text == "Administração" && senhaTextBox.Text == "@dmin321") {…
-
1
votes2
answers71
viewsA: Data query file Settings
You basically have two options: If you want to expose all properties defined in settings, you can change the class modifier Settings of internal for public If nay want to expose all properties…
-
0
votes2
answers256
viewsA: How do I make the program display a message once on the last day of the month?
If I understand your question, you can save in the user settings if they have already been warned or not: if(UltimoDiaDoMes()) { if(!Properties.Settings.Default.AvisouUsuario) {…
-
1
votes2
answers1536
viewsA: Convert string in binary format to PDF
Redeem the bytes of String binary: public Byte[] GetBytesFromBinaryString(String binary) { var list = new List<Byte>(); for (int i = 0; i < binary.Length; i += 8) { String t =…
-
2
votes1
answer58
viewsA: How do you make a form never disappear?
In the form builder do: public Form1() { //Deixa o form transparente this.TransparencyKey = Color.Turquoise; this.BackColor = Color.Turquoise; this.FormBorderStyle = FormBorderStyle.None; //Faz o…
-
0
votes1
answer55
viewsA: Problem with Database Connection
Add the code below before opening the connection: System.Text.EncodingProvider ppp; ppp = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(ppp); Response based in that…
-
1
votes2
answers1129
viewsA: Permission Control in c# and Windows Form
You must build your application in the format "Rules-based" (role-based in English). To do this, you can cause your Forms to inherit some specific access control behaviors. Here you find a detailed…
-
0
votes4
answers590
viewsA: Interaction between forms?
To open form2 do the following: //Limpe o form atual da forma que está fazendo //Crie uma instância de Form2 Form2 form2 = new Form2(); //Exiba o form2 form2.ShowDialog(); //Verifica se o form foi…
-
1
votes1
answer231
viewsA: Datarow.Delete() command by unknown Row index
The DataGridView has the property CurrentCell who owns the property RowIndex, that returns the index of the cell row that is active/selected. To use just do the following: int…
c#answered igventurelli 4,441 -
3
votes3
answers160
viewsA: Check if you have more than one character in a String
You can use the method countMatches, class StringUtils package org.apache.commons.lang3: int count = StringUtils.countMatches("@Teste @Teste", "@");…
-
0
votes3
answers248
viewsA: Using Cellclick to load data from a record
To identify the Pessoa selected you can recover directly from your list through the index of the selected line: private void DataGridView1_SelectionChanged(object sender, EventArgs e) { Pessoa…
-
3
votes2
answers907
viewsA: Get a specific value in an array
Assuming the property you want to display is Nome: public override string ToString() { return "Carrer: " + NrCarreira + "\n1st stop: " + VecParagem.First().Nome + "\nlast stop: " +…
-
2
votes1
answer299
viewsA: Principles of Encapsulation
Based on the comments made on the question and on some of the questions, I take the answer that: Do getters with clone() is indeed the best/correct implementation. With everything, it is necessary…
-
0
votes2
answers407
viewsA: How popular is the list of objects with select(C# and Mysql) results?
You can do with while: string strSQL = "SELECT usuperm.idusuario, usuperm.codfunc, usuperm.perm FROM usuperm INNER JOIN usuarios ON usuarios.idusuario = usuperm.idusuario WHERE usuarios.loginusuario…
-
0
votes1
answer1003
viewsA: execute a code every 5 seconds on Vb.net
You can use the class Timer: 'Declare um variável do tipo Timer: Private tempo As New System.Timers.Timer(5000) '5000 = 5 segundos 'Adicione um handler para capturar o evento tick do timer:…
vb.netanswered igventurelli 4,441 -
3
votes1
answer299
viewsQ: Principles of Encapsulation
I am studying for the Java Programmer SE 7 I certification exam. I use Selftest Kaplan (recommended by Oracle itself). I came across the following question: (I will leave everything in English on…
-
2
votes4
answers2496
viewsA: Do not open more than one form at the same time in C#
From what I found searching, it is not possible to open a form mdi son as dialog. You have two options: Do not "set" the child form as mdi child and treat it as a normal form. So you can open with…
-
1
votes2
answers87
viewsA: Object Reference not set to an instance of an Object?
Your code is in that order: Dim cmd As SqlCommand = New SqlCommand() cmd = Nothing cmd.Connection = con Dim con As SqlConnection = New SqlConnection() con = Nothing con.ConnectionString = "Server =…
-
1
votes1
answer207
viewsA: Expire Mysql user time
Keeping the logic of your implementation, you can declare your SQL statement like this: string sql = "SELECT * FROM users WHERE userName = @login AND userPass = @senha AND DateExpiration >=…
-
0
votes1
answer88
viewsA: Is there a way to join 2 queries of different tables in a single query?
You can use the instruction UNION, but it needs the number and types of the resulting columns to be equal in both queries. Ex: SELECT id, nome FROM alunos UNION SELECT id, nome FROM professores…
-
0
votes2
answers736
viewsA: Error: connection to database already opened
Change if (ConexaoBanco.State == ConnectionState.Closed) For if (ConexaoBanco.State == System.Data.ConnectionState.Closed) Documentation of enum Connectionstate. Based response in that reply.…
-
2
votes3
answers34005
viewsA: Is there an iOS emulator to test an application developed in Xamarin?
Is there an iOS emulator that doesn’t need a real device and runs on Windows or Linux? Not. Some alternatives: Use a virtualization environment (Vmware or something) and create a VM with macOS. With…
-
2
votes3
answers504
viewsA: Javac command with more than one packaged class
You can just do: javac ./com/scja/exam/planetas/*.java ./com/scja/exam/teste/*.java The ./ reference to the root directory of your project. When we want to compile more than one package, we can…
javaanswered igventurelli 4,441 -
8
votes4
answers220
viewsQ: How many Strings are created in the codes below?
How many Strings the JVM actually creates during the execution time of the code snippets below? 1: String s1 = "s1"; 2: String s2 = new String("s2"); 3: String s3 = "s3"; String s4 = s3 + "s4"; 4:…
-
1
votes2
answers2979
viewsA: Invert values from one vector to another vector
You can do it like this: int[] vetor_original = { 1, 2, 3, 4, 5 }; int tamanhoVetorOriginal = vetor_original.length; int[] vetor_copia = new int[tamanhoVetorOriginal]; int…
-
6
votes5
answers1114
viewsA: Save Combobox C# values to database instead of descriptions
To get the expected result (in a "better" implementation), you need to define a class that represents an item in your comboBox. Ex: public class MeuComboBoxItem { public string TextoDoItem { get;…
-
1
votes1
answer1395
viewsA: Join data from two worksheets in Excel
Is there such a possibility? Yes. PROCV In the second sheet include the desired column (NOME) and do the procv: =PROCV(A2;Planilha1.A:B;2;0) Being: A2 - the cell containing the ID Planilha1 - the…
-
4
votes1
answer82
viewsA: VBA Doubt - Forms
Entry mask On the estate InputMask from your textbox, include the mask 000.000.000-00, thus: seuTextBox.InputMask = "000.000.000-00" Mask can receive characters: 0 - Digit (0 to 9, mandatory entry,…
vbaanswered igventurelli 4,441 -
2
votes1
answer46
viewsA: Error inserting data into JPA
Assuming your settings on persistence.xml are correct, do the following: "Write down" your attribute senha with @Column(name="NOME_DA_COLUNA") In the row following the method persist(u), call the…
-
2
votes3
answers972
viewsA: Operation of the switch case
The very one case That is a comparison. It is not possible for you to compare an expression with switch case. Ex: The code below compiles: switch(variavel) { case 1: System.out.println("Número 1");…
-
1
votes1
answer193
viewsA: Export datatable to PDF
You can use the <p:dataExporter>: <h:form> <p:dataTable id="tbl" var="car" value="#{dataExporterView.cars}"> <f:facet name="{Exporters}"> <h:commandLink>…