All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
I am a bit new to java, so bare with me. And ill try to explain as best as i can .
I have to read in a file that that has Student, Employee, Faculty....such as name, last name, salary...etc
Example of a file input
Java Code:
Student, John, Doe, [email]johnDoe[At]yahoo.com[/email], 123,Wonderland Ave, 21323,TX
PhoneNumber,Cell,111,222,3333
Student, Jesus,Satan,[email]jesus[At]satan.com[/email,666, HeavenHell Dr., 666666,CA
PhoneNumber,Work,111,333,5555
Java Code:
while(input.hasNext()){
String [] tokens = input.next().split(",");
String objectType = tokens[0];
if (objectType.equalsIgnoreCase("Person")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]), tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]),Integer.parseInt(tokens[3]));
String emailAddress = tokens[9];
Person p = new Person(firstName, lastName, emailAddress, address,phoneNumber);
person.add(p);
}
else if (objectType.equalsIgnoreCase("Phone Number")){
String type = tokens[1];
int areaCode = Integer.parseInt(tokens[2]);
int prefix = Integer.parseInt(tokens[3]);
int suffix = Integer.parseInt(tokens[4]);
PhoneNumber ph = new PhoneNumber(type,areaCode,prefix,suffix);
phoneList.add(ph);
}
else if (objectType.equalsIgnoreCase("Student")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]),tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
String emailAddress = tokens[9];
String classStanding = tokens[10];
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[2]), Integer.parseInt(tokens[3]),Integer.parseInt(tokens[4]));
Student s = new Student(firstName, lastName,emailAddress,address,phoneNumber, classStanding);
person.add(s);
}
Hello guys!
I have big problem with mergesort in Java. I can't figure out why it do not works.
I need write it on lists using Comparable. Here is piece of code:
Java Code:
class MergeSort{
Comparator _comparator;
List lista = new ArrayList<>();
List list_temp = new ArrayList<>();
MergeSort(Comparator comparator){
_comparator = comparator;
}
void sort(List lista){
this.lista = lista;
mergesort(0, lista.size()-1);
}
void mergesort(int start, int end){
if(start < end){
int mid = start + (end-start)/2;
mergesort(start, mid);
mergesort(mid+1, end);
merge (start, mid, end);
}
}
void merge(int start, int mid, int end){
int i = start;
int j = mid + 1;
int k = start;
for(int h = start; h <= end; h++)
list_temp.add(lista.get(h));
while (i <= mid && j <= end) {
if (_comparator.compare(list_temp.get(i),list_temp.get(j)) <= 0) {
lista.set(k, list_temp.get(i));
i++;
}
else{
lista.set(k, list_temp.get(j));
j++;
}
k++;
while (i <= mid) {
lista.set(k, list_temp.get(i));
k++;
i++;
}
}
}
final class NaturalComparator implements Comparator{
public static final NaturalComparator INSTANCE = new NaturalComparator();
NaturalComparator(){}
@Override
public int compare(Object left, Object right) throws ClassCastException{
return ((Comparable) left).compareTo(right);
}
}
Thnak you for any advice!
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
I am a bit new to java, so bare with me. And ill try to explain as best as i can .
I have to read in a file that that has Student, Employee, Faculty....such as name, last name, salary...etc
Example of a file input
Java Code:
Student, John, Doe, [email]johnDoe[At]yahoo.com[/email], 123,Wonderland Ave, 21323,TX
PhoneNumber,Cell,111,222,3333
Student, Jesus,Satan,[email]jesus[At]satan.com[/email,666, HeavenHell Dr., 666666,CA
PhoneNumber,Work,111,333,5555
Java Code:
while(input.hasNext()){
String [] tokens = input.next().split(",");
String objectType = tokens[0];
if (objectType.equalsIgnoreCase("Person")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]), tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]),Integer.parseInt(tokens[3]));
String emailAddress = tokens[9];
Person p = new Person(firstName, lastName, emailAddress, address,phoneNumber);
person.add(p);
}
else if (objectType.equalsIgnoreCase("Phone Number")){
String type = tokens[1];
int areaCode = Integer.parseInt(tokens[2]);
int prefix = Integer.parseInt(tokens[3]);
int suffix = Integer.parseInt(tokens[4]);
PhoneNumber ph = new PhoneNumber(type,areaCode,prefix,suffix);
phoneList.add(ph);
}
else if (objectType.equalsIgnoreCase("Student")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]),tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
String emailAddress = tokens[9];
String classStanding = tokens[10];
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[2]), Integer.parseInt(tokens[3]),Integer.parseInt(tokens[4]));
Student s = new Student(firstName, lastName,emailAddress,address,phoneNumber, classStanding);
person.add(s);
}
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
I am a bit new to java, so bare with me. And ill try to explain as best as i can .
I have to read in a file that that has Student, Employee, Faculty....such as name, last name, salary...etc
Example of a file input
Java Code:
Student, John, Doe, [email]johnDoe[At]yahoo.com[/email], 123,Wonderland Ave, 21323,TX
PhoneNumber,Cell,111,222,3333
Student, Jesus,Satan,[email]jesus[At]satan.com[/email,666, HeavenHell Dr., 666666,CA
PhoneNumber,Work,111,333,5555
Java Code:
while(input.hasNext()){
String [] tokens = input.next().split(",");
String objectType = tokens[0];
if (objectType.equalsIgnoreCase("Person")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]), tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]),Integer.parseInt(tokens[3]));
String emailAddress = tokens[9];
Person p = new Person(firstName, lastName, emailAddress, address,phoneNumber);
person.add(p);
}
else if (objectType.equalsIgnoreCase("Phone Number")){
String type = tokens[1];
int areaCode = Integer.parseInt(tokens[2]);
int prefix = Integer.parseInt(tokens[3]);
int suffix = Integer.parseInt(tokens[4]);
PhoneNumber ph = new PhoneNumber(type,areaCode,prefix,suffix);
phoneList.add(ph);
}
else if (objectType.equalsIgnoreCase("Student")){
String firstName = tokens[1];
String lastName = tokens[2];
Address address = new Address (Integer.parseInt(tokens[3]), Integer.parseInt(tokens[4]),tokens[5], tokens[6], tokens[7], Integer.parseInt(tokens[8]));
String emailAddress = tokens[9];
String classStanding = tokens[10];
PhoneNumber phoneNumber = new PhoneNumber(tokens[1],Integer.parseInt(tokens[2]), Integer.parseInt(tokens[3]),Integer.parseInt(tokens[4]));
Student s = new Student(firstName, lastName,emailAddress,address,phoneNumber, classStanding);
person.add(s);
}
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
Hi! I've been doing some work with Java Networking, specifically a Chat that sends a string to a server which then broadcasts to the other clients. I would like to create a game, but I am wondering how I would send data to the server in such a way that when it goes to the other clients, it doesn't confuse information.
For instance, how would I send the x and y coordinates of an object to a server. Please note that I would have other variables that might not be integers/doubles/floats, but maybe booleans, chars, or strings.
However, one thing that I was thinking is, would it be better (and possible) to send a whole class, such as a "spaceship" class or something like that. That way, the class would already contain all the variables.
In any case, thanks in advance!
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
All times are GMT +2. The time now is 02:57 AM.
VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2006 - 2012, Java Programming Forum
Hi, i've this code
PHP Code:
<%@ taglib prefix="c" uri="http://ift.tt/QfKAz6" %>
<%@page import="Javabean.Articolo"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String nome="porcodio";
%>
<div> ${nome}</div>
</body>
</html>