blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
89fbe23094aa0ad684f29239f50ac985cacdae58
c540a3c446acd2b9932f8e1fdc8a3ceed6298a05
/src/com/solin/mapper/UserMapper.java
e3aeff02d7405fb45736d00929859d4e305a8eed
[]
no_license
yongxingchsc/template
7d3369b59e09d9e7815cef8d582c79054134d46d
dc1d3696285051a0cf93f51298ccc02e9adaac8d
refs/heads/master
2020-03-30T00:31:49.158545
2018-09-27T04:23:25
2018-09-27T04:23:25
150,528,628
0
0
null
null
null
null
UTF-8
Java
false
false
333
java
package com.solin.mapper; import com.solin.entity.User; public interface UserMapper { int deleteByPrimaryKey(Integer id); int insert(User record); int insertSelective(User record); User selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(User record); int updateByPrimaryKey(User record); }
e7330af1df802fec57adda19a3cb33015b1a867d
de33901c47658a5b03c3fdd95a183161de27e1f4
/finecache/src/main/java/fz/cache/FineCache.java
3561500e926c3535a1d9b38a19f7587f291fefc4
[]
no_license
httpping/FineCache
2180df0118367435cf5bea422c8fd59a3b42deed
8c450dc58a0bc2b83d8fe602cb28946983a701e2
refs/heads/master
2020-04-15T15:47:03.813989
2019-01-21T01:15:57
2019-01-21T01:15:57
164,808,237
1
0
null
null
null
null
UTF-8
Java
false
false
10,620
java
package fz.cache; /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . __ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 佛祖保佑 永无BUG */ import android.content.Context; import org.reactivestreams.Publisher; import java.util.List; import java.util.Map; import fz.cache.core.DefaultEncryption; import fz.cache.core.FineFacadeImpl; import fz.cache.core.GsonSerializer; import fz.cache.core.DBStorage; import fz.cache.core.weiget.Encryption; import fz.cache.core.weiget.FacadeApi; import fz.cache.core.weiget.Serializer; import fz.cache.core.weiget.Storage; import fz.cache.db.DataInfo; import io.reactivex.Flowable; import io.reactivex.FlowableEmitter; import io.reactivex.FlowableOnSubscribe; import io.reactivex.functions.Function; import io.reactivex.internal.operators.flowable.FlowableAll; import io.reactivex.internal.operators.flowable.FlowableCache; /** * 项目名称: z * 类描述: * 创建时间:2019/1/7 11:44 * * @author tanping */ public class FineCache { Encryption encryption; Serializer serializer; Storage storage; FacadeApi apiImpl; private static FineCache fineCache; public static <T> T get(String key) { return get(DataInfo.DEFAULT_GROUP, key, null); } public static <T> T get(String key, T defaultValue) { return get(DataInfo.DEFAULT_GROUP, key, defaultValue); } public static <T> T get(String group, String key, T defaultValue) { return getInstance().apiImpl.get(group, key, defaultValue); } public static <T> void put(String key, T value) { put(DataInfo.DEFAULT_GROUP, key,0, value); } public static <T> void put(String key, T value,int expire) { put(DataInfo.DEFAULT_GROUP, key,0, value); } public static <T> void put(String group, String key,int expire, T value) { getInstance().apiImpl.put(group, key, expire, value); } /// list 或 set 数据格式相关 API public static <T> void lpush(String name, T value) { lpush(DataInfo.DEFAULT_GROUP, name, value); } public static <T> void lpush(String name, int expire,T value) { lpush(DataInfo.DEFAULT_GROUP, name, expire, value); } public static <T> void lpush(String group, String name, T value) { getInstance().apiImpl.lpush(group, name,0, value); } public static <T> void lpush(String group, String name,int expire, T value) { getInstance().apiImpl.lpush(group, name,expire, value); } public static <T> Flowable<Boolean> lAsyncPush(String name, int expire,T value) { return lAsyncPush(DataInfo.DEFAULT_GROUP, name, expire, value); } public static <T> Flowable<Boolean> lAsyncPush(final String group,final String name,final int expire,final T value) { return Flowable.just(group).map(new Function<String, Boolean>() { @Override public Boolean apply(String s) throws Exception { try { getInstance().apiImpl.lpush(group, name,expire, value); } catch (Exception e) { e.printStackTrace(); return false; } return true; } }); // getInstance().apiImpl.lpush(group, name,expire, value); } /** * value 唯一 相当于 set, 用lpush 和 lpushUniqe 存同样的数据会重复。 * * @param name * @param value * @param <T> */ public static <T> void lpushUniqe(String name, T value) { lpushUniqe(DataInfo.DEFAULT_GROUP, name, 0,value); } public static <T> void lpushUniqe(String name,int expire, T value) { lpushUniqe(DataInfo.DEFAULT_GROUP, name, expire,value); } public static <T> void lpushUniqe(String group, String name,int expire, T value) { getInstance().apiImpl.lpushUniqe(group, name,expire, value); } public static List lget(String name) { return lget(DataInfo.DEFAULT_GROUP, name); } public static List lget(String group, String name) { return getInstance().apiImpl.lget(group, name); } public static Flowable<List> lAsyncGet( final String name){ return lAsyncGet(DataInfo.DEFAULT_GROUP,name); } public static Flowable<List> lAsyncGet(final String group, final String name) { return Flowable.just(group).map(new Function<String, List>() { @Override public List apply(String s) throws Exception { try { return getInstance().apiImpl.lget(group, name); } catch (Exception e) { e.printStackTrace(); return null; } } }); } public static <T> T lpop(String name) { return lpop(DataInfo.DEFAULT_GROUP, name); } public static <T> T lpop(String group, String name) { return getInstance().apiImpl.lpop(group, name); } public static <T> T lrpop(String name) { return lrpop(DataInfo.DEFAULT_GROUP, name); } public static <T> T lrpop(String group, String name) { return getInstance().apiImpl.lrpop(group, name); } public static boolean isLexist(String name) { return isLexist(DataInfo.DEFAULT_GROUP, name); } public static boolean isLexist(String group, String name) { return getInstance().apiImpl.isLexist(group, name); } public static int lremove(String name) { return lremove(DataInfo.DEFAULT_GROUP, name); } public static int lremove(String group, String name) { return getInstance().apiImpl.lremove(group, name); } public static int lremoveAll() { return getInstance().apiImpl.lremoveAll(); } public static int llen(String name) { return llen(DataInfo.DEFAULT_GROUP, name); } public static int llen(String group, String name) { return getInstance().apiImpl.llen(group, name); } // map 相关API public static <T> void hput(String name, String key, T value) { hput(DataInfo.DEFAULT_GROUP, name, key, 0,value); } public static <T> void hput(String name, String key,int expire, T value) { hput(DataInfo.DEFAULT_GROUP, name, key,expire, value); } public static <T> void hput(String group, String name, String key,int expire, T value) { getInstance().apiImpl.hput(group, name, key,expire,value); } public static Map<String, ?> hget(String name) { return hget(DataInfo.DEFAULT_GROUP, name); } public static Map<String, ?> hget(String group, String name) { return getInstance().apiImpl.hget(group, name); } public static Map<String, ?> hget(String group, String name, String... key) { return getInstance().apiImpl.hget(group, name, key); } public static boolean isHexist(String name) { return isHexist(DataInfo.DEFAULT_GROUP, name); } public static boolean isHexist(String group, String name) { return isHexist(DataInfo.DEFAULT_GROUP, name, null); } public static boolean isHexist(String group, String name, String key) { return getInstance().apiImpl.isHexist(group, name, key); } public static int hremove(String name) { return hremove(DataInfo.DEFAULT_GROUP, name); } public static int hremove(String group, String name) { return hremove(DataInfo.DEFAULT_GROUP, name, null); } public static int hremove(String group, String name, String key) { return getInstance().apiImpl.hremove(group, name, key); } public static int hlen(String name) { return hlen(DataInfo.DEFAULT_GROUP, name); } public static int hlen(String group, String name) { return getInstance().apiImpl.hlen(group, name); } @Deprecated public static List<DataInfo> groups(){ return getInstance().apiImpl.groups(); } /** * 监控使用 * @param group * @return */ @Deprecated public static List getAll(String group,int type) { return getInstance().apiImpl.getAll(group,type); } @Deprecated public static <T> T dataDecode(DataInfo dataInfo){ return getInstance().apiImpl.dataDecode(dataInfo); } private static FineCache getInstance() { return fineCache; } /** * build FineCache */ public static class Builder { Context context; public Builder(Context context) { this.context = context.getApplicationContext(); fineCache = new FineCache(); } /** * 创建builder * * @param context * @return */ public synchronized static Builder created(Context context) { Builder builder = new Builder(context); return builder; } public Builder encryption(Encryption encryption) { fineCache.encryption = encryption; return this; } public Builder storage(Storage storage) { fineCache.storage = storage; return this; } public Builder serializer(Serializer serializer) { fineCache.serializer = serializer; return this; } public Builder facadeImpl(FacadeApi api) { fineCache.apiImpl = api; return this; } public FineCache build() { if (fineCache.serializer == null) { fineCache.serializer = new GsonSerializer(); } if (fineCache.storage == null) { fineCache.storage = new DBStorage(context); } if (fineCache.encryption == null) { fineCache.encryption = new DefaultEncryption(); } if (fineCache.apiImpl == null) { fineCache.apiImpl = new FineFacadeImpl(fineCache.storage, fineCache.serializer, fineCache.encryption); } return fineCache; } } }
3c9a064916a7c4c43c2ee065ccffd28b0d3f5305
342f756d8fce69b1074d7f2da041c8e772fef2d2
/src/main/java/br/com/pocbackend/springboot/service/AlunoService.java
5d5a2b6bcdde379fd2959455f10a04787405a00d
[]
no_license
crisgit/backendtcc
c52cc38b9cc46eb0a80bdc9f6c2ac87e2afc848e
f3fa8769bf5c268ed6b1dc36b4bb5d46d2373ea4
refs/heads/master
2020-05-16T00:52:42.148549
2019-04-24T02:45:35
2019-04-24T02:45:35
182,589,105
1
0
null
null
null
null
UTF-8
Java
false
false
2,158
java
package br.com.pocbackend.springboot.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import br.com.pocbackend.springboot.model.Aluno; import br.com.pocbackend.springboot.model.Nota; import br.com.pocbackend.springboot.service.mapper.AlunoMapper; import br.com.pocbackend.springboot.service.queryconstants.Queries; @Service public class AlunoService { @Autowired private JdbcTemplate jdbcTemplate; @Autowired private NotaService notaService; public List<Aluno> retrieveAllAlunos() { List<Aluno> alunos = jdbcTemplate.query(Queries.LIST_ALUNOS, new BeanPropertyRowMapper<Aluno>(Aluno.class)); return alunos; } public Aluno retrieveAluno(Long idAluno) { return (Aluno) jdbcTemplate.queryForObject(Queries.LIST_ALUNOS_BY_ID, new Object[] { idAluno }, new BeanPropertyRowMapper<Aluno>(Aluno.class)); } public Aluno retrieveAlunoByEmail(String email) { Aluno aluno = null; try { aluno = (Aluno) jdbcTemplate.queryForObject(Queries.LIST_ALUNOS_BY_EMAIL, new Object[] { email }, new AlunoMapper()); // if(aluno != null) { // List<Nota> notas = notaService.retrieveNotasPorMatricula(aluno.getMatricula().getIdMatricula()); // } } catch(EmptyResultDataAccessException e) { return aluno; } return aluno; } public int insertAluno(Aluno aluno) { return jdbcTemplate.update(Queries.INSERT_ALUNO, new Object[] { aluno.getNome(), aluno.getCpf(), aluno.getEndereco(), aluno.getEstado(), aluno.getMunicipio(), aluno.getTelefone(), aluno.getUsuario().getIdUsuario() }); } public int updateAluno(Aluno aluno) { return jdbcTemplate.update(Queries.UPDATE_ALUNO, new Object[] { aluno.getNome(), aluno.getCpf(), aluno.getEndereco(), aluno.getEstado(), aluno.getMunicipio(), aluno.getTelefone(), aluno.getIdAluno() }); } public int deleteAluno(Long idAluno) { return jdbcTemplate.update(Queries.DElETE_ALUNO, new Object[] { idAluno }); } }
b4119f6f367e7af8f609bda7eae017e3be7a27ba
5d4e437dfad45e43e9cfcdb8fdf72587a69edb39
/Programa.java
e53762389d82c6b3439719234226ec853ee10518
[]
no_license
emersonandre/prog1
22d138158a67ef05b95e0945186bf1413e1612bd
51df3ba24883f6244d8404b6900e114103346fe2
refs/heads/main
2023-03-08T14:47:06.200262
2021-02-26T12:49:45
2021-02-26T12:49:45
342,329,959
0
0
null
null
null
null
UTF-8
Java
false
false
132
java
public class Programa { public static void main(String[] args) { System.out.println("Olá Mundo!"); } }
14c50293f9f5fdc5403ef1aafa768176094929f2
7d0d9f657f992e27e82efb8457e69ed856ca287d
/DesignPattern/src/decorator/LuxuryCar.java
95397c5daebf2c01f8b8ae71b36ddafe151d99da
[]
no_license
Mananp96/Java-OOPS_Design-Pattern
560d7238e18a6d62e30772e973c640e97358e334
cbc8035f439d1d26024189c3f284c8d535ab5fe7
refs/heads/master
2022-04-12T17:11:41.282678
2020-03-31T02:06:06
2020-03-31T02:06:06
null
0
0
null
null
null
null
UTF-8
Java
false
false
217
java
package decorator; public class LuxuryCar extends CarDecorator{ public LuxuryCar(Car c) { super(c); } public void assemble() { super.assemble(); System.out.println("Adding features of Luxury Car."); } }
ac8ae79f306ec507d2333157d253e2c10ac0f926
ec6654bb3d17548b93407b437fbcea9d88fb1701
/JavaWebModule/JavaDBFundamentals/HibernateCodeFirst_Exercise/UniversitySystem/src/main/java/entities/Teacher.java
f548af6cd9e7825d6921581cdcd5ac9f602d1228
[ "MIT" ]
permissive
boggroZZdev/SoftUniHomeWork
12255d965cc6542708e10984606375e1949a0a49
9a19f70c432e457f22bc021d1b3ee374232acbab
refs/heads/master
2021-09-10T20:49:23.844590
2018-04-02T04:29:43
2018-04-02T04:29:43
105,696,030
0
0
null
null
null
null
UTF-8
Java
false
false
972
java
package entities; import javax.persistence.*; import java.math.BigDecimal; import java.util.Set; @Entity @Table(name = "teachers") public class Teacher extends Person { private String email; private BigDecimal salaryPerHour; private Set<Course> taughtCourses; @Column(name = "email") public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Column(name = "salary_per_hour") public BigDecimal getSalaryPerHour() { return salaryPerHour; } public void setSalaryPerHour(BigDecimal salaryPerHour) { this.salaryPerHour = salaryPerHour; } @OneToMany(mappedBy = "teacher", targetEntity = Course.class) public Set<Course> getTaughtCourses() { return taughtCourses; } public void setTaughtCourses(Set<Course> taughtCourses) { this.taughtCourses = taughtCourses; } }
54800dc753ea680660327a43d4d520a3390a62cf
2867837925f1bf96b13302fe3f720a60efd9b45b
/SciCalculator.java
31c043da3d87b6811ba6f50863df0722d8e1599f
[]
no_license
morgan-cobb/ScientificCalculator
f1b9f16d06035e40f0d46e29ddc526dd35940eea
ccff4647e758e428847badebbb250bea5bd99e23
refs/heads/master
2023-02-03T11:09:22.263605
2020-12-17T19:43:19
2020-12-17T19:43:19
308,155,834
0
0
null
null
null
null
UTF-8
Java
false
false
5,134
java
import java.util.Scanner; import java.text.DecimalFormat; public class SciCalculator { public static void main(String[] args) { Scanner scan = new Scanner(System.in); DecimalFormat df2 = new DecimalFormat("##.##"); //declared variables here so it would be less confusing to read as you go along double ans = 0.0; boolean calculate = true; int nCalc = 0; /*This stands for the number of calculations done already*/ double sum = 0; double avg; boolean play; //while this is true the calculator will continue to work. Case 0 of the switch turns calculate to false to end the program while(calculate) { sum += ans; System.out.println("Current Result:"+ ans + "\n"); System.out.println("Calculator Menu\n --------------- \n 0.Exit Program \n 1.Addition \n 2.Subtraction \n 3.Multiplication \n 4.Division"); System.out.println(" 5.Exponentiation \n 6.Logarithm \n 7.Display Average"); //Had to have a second while loop so it didn't continue to print the menu play = true; while(play) { System.out.println("Enter Menu Selection: "); int selection = scan.nextInt(); //Here I used a switch for the user to decide which function of the calculator they wanted to use. switch(selection) { case 0: //Exit Program System.out.println("Thanks for using this calculator. Goodbye!"); play = false; calculate = false; nCalc++; break; case 1: //Addition System.out.println("Enter first operand: "); double firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); double secondOp = scan.nextDouble(); ans = firstOp + secondOp; nCalc++; play = false; break; case 2: //Subtraction System.out.println("Enter first operand: "); firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); secondOp = scan.nextDouble(); ans = firstOp - secondOp; nCalc++; play = false; break; case 3: //Multiplication System.out.println("Enter first operand: "); firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); secondOp = scan.nextDouble(); ans = firstOp * secondOp; nCalc++; play = false; break; case 4: //Division System.out.println("Enter first operand: "); firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); secondOp = scan.nextDouble(); ans = firstOp / secondOp; nCalc++; play = false; break; case 5: //Exponentiation System.out.println("Enter first operand: "); firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); secondOp = scan.nextDouble(); ans = Math.pow(firstOp, secondOp); nCalc++; play = false; break; case 6: //Logarithm System.out.println("Enter first operand: "); firstOp = scan.nextDouble(); System.out.println("Enter second operand: "); secondOp = scan.nextDouble(); ans = (Math.log(secondOp)) / Math.log(firstOp); nCalc++; play = false; break; case 7: //Display Average if (nCalc < 1) { System.out.println("Error: No calculations yet to average!"); } else { avg = sum/nCalc; System.out.println("Sum of calculations:" + sum + "\nNumber of calculations:" + nCalc + "\nAverage of calculations:" + df2.format(avg)); } break; default: //Print the error if the correct operation is not chosen System.out.println("Error: Invalid selection!"); } } } } }
9be0baac629295eb596ce000d7f1f7ebae1eeedd
f4c7c5a0aee06f72123a7abf361aaf87a9379041
/app/src/main/java/com/test/footballapi/data/network/NetworkManager.java
343554ac973574dd3cc3fa054bb307f73109ab60
[]
no_license
DziubaVLaD/FootballApi
48a07c5ec4e54d63c35a27c659160bcccb8ce504
7531b7d71e8fe4370a05ad09b716628c9c6e4191
refs/heads/master
2023-02-25T20:27:36.176295
2021-01-27T17:36:53
2021-01-27T17:36:53
331,643,349
0
0
null
null
null
null
UTF-8
Java
false
false
4,066
java
package com.test.footballapi.data.network; import android.content.Context; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.NetworkRequest; import android.os.Build; import android.util.Log; import com.test.footballapi.data.model.NetworkEvent; import org.jetbrains.annotations.NotNull; import io.reactivex.Flowable; import io.reactivex.processors.PublishProcessor; public class NetworkManager { private static final String TAG = NetworkManager.class.getSimpleName(); private boolean isConnected; private final Context context; private final PublishProcessor<NetworkEvent> networkEventPublishProcessor = PublishProcessor.create(); private final ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(@NotNull Network network) { super.onAvailable(network); boolean isConnected = isNetworkConnected(); if (NetworkManager.this.isConnected != isConnected) { NetworkManager.this.isConnected = isConnected; Log.d(TAG, "onAvailable() called with: network = [" + network + "], connected " + isConnected); NetworkEvent networkEvent = new NetworkEvent(); networkEvent.setConnected(isConnected); networkEventPublishProcessor.onNext(networkEvent); } } @Override public void onLost(@NotNull Network network) { super.onLost(network); boolean isConnected = isNetworkConnected(); if (NetworkManager.this.isConnected != isConnected) { NetworkManager.this.isConnected = isConnected; Log.d(TAG, "onLost() called with: network = [" + network + "], connected " + isConnected); NetworkEvent networkEvent = new NetworkEvent(); networkEvent.setConnected(isConnected); networkEventPublishProcessor.onNext(networkEvent); } } }; public NetworkManager(Context context) { this.context = context.getApplicationContext(); } public void registerNetworkCallback() { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkRequest.Builder builder = new NetworkRequest.Builder(); connectivityManager.registerNetworkCallback(builder.build(), networkCallback); } public void unregisterNetworkCallback() { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); try { connectivityManager.unregisterNetworkCallback(networkCallback); } catch (IllegalArgumentException ignored) { } } public Flowable<NetworkEvent> subscribeOnNetworkEvents() { return networkEventPublishProcessor; } public boolean isConnected() { return isNetworkConnected(); } private boolean isNetworkConnected() { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { if (Build.VERSION.SDK_INT < 23) { final NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null) { return (ni.isConnected() && (ni.getType() == ConnectivityManager.TYPE_WIFI || ni.getType() == ConnectivityManager.TYPE_MOBILE)); } } else { final Network n = cm.getActiveNetwork(); if (n != null) { final NetworkCapabilities nc = cm.getNetworkCapabilities(n); if (nc != null) { return (nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) || nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)); } } } } return false; } }
6a037b9489995ce2b47cae4aaee0c920add07755
c7a45981df1b0c8f481280efacc0bb80bba69759
/kuruvaSatyaGanesh-maven_OOPS/src/main/java/com/epam/kuruvaSatyaGanesh_maven_OOPS/sweets/Kajukatli.java
746230ad21afa4b1938d9c2c74e385e95a084477
[]
no_license
kuruvasatya/kuruvaSatyaGanesh-Maven
1d1c546db5ab7e412ee71303a094f7aaf30c2f79
3bfefcf8fd9e0dfe83ecf40e6c6fa5c179f898af
refs/heads/master
2021-01-01T03:02:59.424013
2020-02-08T16:02:21
2020-02-08T16:02:21
239,153,928
0
0
null
2020-10-13T19:22:48
2020-02-08T15:24:33
Java
UTF-8
Java
false
false
198
java
package com.epam.kuruvaSatyaGanesh_maven_OOPS.sweets; public class Kajukatli extends Sweets { public Kajukatli(String name, int price, int weight) { super(name, price, weight); } }
5dd08994b2ed74afb93159c0e0ab0ae7ca08c408
297c127119b0c5ad6ee5ce0d04ce6ab89f66e50d
/ConcertReservationSystem4/src/com/concert/model/Member.java
972a9bae938d4772d5074e6512b1e21ef5ebbda9
[]
no_license
helloJunejun/WorkSpace_JAVA
2c3867e2126dd7078b52e27e9cf391718239705f
dea6b88c2770f6ae75ac99cf8a010c90d27977bb
refs/heads/main
2023-06-05T05:34:38.996718
2021-06-27T14:34:30
2021-06-27T14:34:30
375,957,862
1
0
null
null
null
null
UTF-8
Java
false
false
3,704
java
package com.concert.model; /** * <pre> * * 이게 도메인 클래스다 속성 -> 생성자 -> get,set -> equal,hashcode -> tostring * * 회원 정보 도메인 클래스 * -- encapsulation 설계 반영 변경 * ## 회원 검증조건 * 1. 아이디 * 2. 마일리지 * 3. ... * * 1. 아이디 * 2. 비밀번호 * 3. 이름 * 4. 휴대폰 * 5. 이메일 * 6. 가입일 * 7. 등급 * 8. 마일리지 * 9. 담당자 * </pre> * @author 유준성 * @version ver.1.0 * @since jdk1.8 */ public class Member { /** 회원id : 식별키 */ public String memberId; /** 비밀번호 : 필수 */ public String memberPw; /** 이름 : 필수 */ public String name; /** 휴대폰 : 필수 */ public String mobile; /** 등급 : 필수 */ public String grade; /** 돈 : 필수 */ public int money; /** * 기본 생성자 */ public Member() { } /** * 필수 멤버 변수 초기화 * @param memberId * @param memberPw * @param name * @param mobile */ public Member(String memberId, String memberPw, String name, String mobile) { this.memberId = memberId; this.memberPw = memberPw; this.name = name; this.mobile = mobile; } /** * 선택 멤버 변수 초기화 * @param memberId * @param memberPw * @param name * @param mobile * @param grade * @param money */ public Member(String memberId, String memberPw, String name, String mobile, String grade, int money) { this(memberId, memberPw, name, mobile); this.grade = grade; this.money = money; } /** * @return the memberId */ public String getMemberId() { return memberId; } /** * @param memberId the memberId to set */ public void setMemberId(String memberId) { this.memberId = memberId; } /** * @return the memberPw */ public String getMemberPw() { return memberPw; } /** * @param memberPw the memberPw to set */ public void setMemberPw(String memberPw) { this.memberPw = memberPw; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the mobile */ public String getMobile() { return mobile; } /** * @param mobile the mobile to set */ public void setMobile(String mobile) { this.mobile = mobile; } /** * @return the grade */ public String getGrade() { return grade; } /** * @param grade the grade to set */ public void setGrade(String grade) { this.grade = grade; } /** * @return the money */ public int getMoney() { return money; } /** * @param money the money to set */ public void setMoney(int money) { this.money = money; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((memberId == null) ? 0 : memberId.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Member other = (Member) obj; if (memberId == null) { if (other.memberId != null) return false; } else if (!memberId.equals(other.memberId)) return false; return true; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(memberId); builder.append(", "); builder.append(memberPw); builder.append(", "); builder.append(name); builder.append(", "); builder.append(mobile); builder.append(", "); builder.append(grade); builder.append(", "); builder.append(money); return builder.toString(); } }
c6d08589cf7ec2ad7b9d2f109d5ed65c77e7189f
54313173e7d7fc6ec868bd81162a77efeb9b5e60
/src/main/java/wiki/zimo/scorecrawler/domain/Visitor.java
0b15d243ba6ded231fc4af52e617e55eaa417339
[ "Apache-2.0" ]
permissive
iNetty/yibinu-score-crawler
4a59dfd0f133bd0876fff88b6304c09676e74eb0
e1b2a0cb75408b7df5e38594954b85aac88eadd9
refs/heads/master
2022-11-08T18:12:08.334003
2020-07-04T03:29:17
2020-07-04T03:29:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
953
java
package wiki.zimo.scorecrawler.domain; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import java.util.Objects; @Entity public class Visitor { private int id; private Integer num; @Id @Column(name = "Id") public int getId() { return id; } public void setId(int id) { this.id = id; } @Basic @Column(name = "num") public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Visitor visitor = (Visitor) o; return id == visitor.id && Objects.equals(num, visitor.num); } @Override public int hashCode() { return Objects.hash(id, num); } }
42a3a0afe551a157218db0eab413de1d33170b50
4e0807db3ecdf628334ed8fde157b5b2fed70882
/src/com/ebdev/lawservices/db/tables/ClientTable.java
b463f8c8e281ec396809309e64c5cd872eaa33c9
[]
no_license
EB-Dev-2015/law-services
a67feb7be71b7abbfcd70cb927f845cfe3dd6a38
793d08ac315e1edaa4caeeddc464eea26da9d1bf
refs/heads/master
2021-01-10T17:10:07.947675
2015-10-18T19:33:06
2015-10-18T19:33:06
44,140,139
0
0
null
null
null
null
UTF-8
Java
false
false
1,142
java
package com.ebdev.lawservices.db.tables; /** * Client Table information. * * @version 1.0 * @since 8/01/2015 */ public class ClientTable { /** Name of Client Table. */ public final static String TABLE_NAME = "client"; /** Name of Client ID column. */ public final static String COLUMN_CLIENT_ID = "client_id"; /** Name of Client First Name column. */ public final static String COLUMN_CLIENT_FIRST_NAME = "client_fname"; /** Name of Client Last Name column. */ public final static String COLUMN_CLIENT_LAST_NAME = "client_lname"; /** Name of Client Phone column. */ public final static String COLUMN_PHONE = "phone"; /** Name of Client Address column. */ public final static String COLUMN_ADDRESS = "address"; /** Name of Client Email column. */ public final static String COLUMN_EMAIL = "email"; /** Name of Client Note column. */ public final static String COLUMN_NOTE = "note"; /** Array of all Client Column Names. */ public final static String[] ALL_COLUMNS = {COLUMN_CLIENT_ID, COLUMN_CLIENT_FIRST_NAME, COLUMN_CLIENT_LAST_NAME, COLUMN_PHONE, COLUMN_ADDRESS, COLUMN_EMAIL, COLUMN_NOTE}; }
b4d603c9edc2bbe0e1ee183eb183542efade4ec3
18ad8213a95cce1d8c3e10188f9f605f2f2e77d6
/Spring 5_Hibernate 5_Spring Boot 2_REST/SpringRESTClient/src/main/java/com/purplewisteria/SpringRESTClient/config/RestTemplateConfig.java
7372e1843cab83c5c85e36f6554c01eb1369c892
[]
no_license
vishucloud/Project_1
3a52f507f3f0322286d05bbc9ab0f463cfa5364a
48cf1d4877ba421a4af3f8215536b9ce05cf5d9e
refs/heads/master
2023-04-14T06:53:34.913898
2021-04-28T20:39:32
2021-04-28T20:39:32
362,598,377
0
0
null
null
null
null
UTF-8
Java
false
false
1,015
java
package com.purplewisteria.SpringRESTClient.config; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; /* Building an application that uses Spring’s RestTemplate to consume a RESTful service. * A more useful way to consume a REST web service is programmatically.. * Spring provides a convenient template class called RestTemplate * RestTemplate makes interacting with most RESTful services a one-line incantation a and it can even bind that data to custom domain types. */ /* Accessing a third-party REST service inside a Spring application revolves around the use of the Spring RestTemplate class */ @Configuration public class RestTemplateConfig { @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) { return builder.build(); } } // Reference: https://spring.io/guides/gs/consuming-rest/
9d180bf6663a6568521f33954dfd7994e501d0cb
60f4f2d0bfb9376d215828505ae654ce1aea1a80
/src/main/java/me/zkingofkill/spartan/rankup/engines/EngineConfig.java
a7303271813e508df22e33e09824ebb988105fde
[]
no_license
PedroCavalcanti0001/SpartanRankup
c7e831b004e31f08e4e39f6f3ffce2d4a10097d2
4d64c89a32bca90e2b235c09f2e83453985f06ee
refs/heads/master
2022-03-03T21:44:46.368850
2019-08-21T14:16:58
2019-08-21T14:16:58
203,599,150
0
0
null
null
null
null
UTF-8
Java
false
false
2,708
java
package me.zkingofkill.spartan.rankup.engines; import me.zkingofkill.spartan.rankup.SpartanRankup; import me.zkingofkill.spartan.rankup.database.Cache; import me.zkingofkill.spartan.rankup.objects.Categorie; import me.zkingofkill.spartan.rankup.objects.Rank; import me.zkingofkill.spartan.rankup.utils.ItemStackBuilder; import me.zkingofkill.spartan.rankup.utils.Utils; import org.apache.commons.lang.math.NumberUtils; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; import java.util.stream.Collector; import java.util.stream.Collectors; public class EngineConfig { public void setup(){ FileConfiguration config = SpartanRankup.getInstance().getConfig(); for(String category : config.getConfigurationSection("categories").getKeys(false)){ String name = config.getString("categories."+category+".name").replace("&","§"); boolean glow = config.getBoolean("categories."+category+".glow"); Material m = Material.getMaterial(Integer.valueOf(config.getString("categories."+category+".item-id").split(":")[0])); int data = Integer.valueOf(config.getString("categories."+category+".item-id").split(":")[1]); ArrayList<Rank> rk = new ArrayList<>(); List<String> lore = config.getStringList("globallore"); for(String rank : config.getConfigurationSection("categories."+category+".ranks").getKeys(false)) { double stars = config.getDouble("categories."+category+".ranks."+rank+".requeriments.stars"); double yolks = config.getDouble("categories."+category+".ranks."+rank+".requeriments.yolks"); Map<String, Boolean> permissions = new HashMap<>(); config.getStringList("categories."+category+".ranks."+rank+".permissions").forEach(a -> permissions.put(a, true)); ArrayList<String> commands = (ArrayList<String>) config.getStringList("categories."+category+".ranks"+rank+".commands"); String prefix = config.getString("categories."+category+".ranks."+rank+".prefix").replace("&","§"); int position = config.getInt("categories."+category+".ranks."+rank+".position"); rk.add(new Rank(rank, position, stars, yolks, prefix, permissions, commands)); } ItemStack item = new ItemStackBuilder(m).setName(name).setDurability(data).setLore(lore).build(); Categorie categorie = new Categorie(category, name, item, glow, rk); SpartanRankup.getInstance().getCache().categories.add(categorie); } } }
d9bfff9969d601e27cd9623a4898a51afa17e4d7
3f8c113a5f3607deeee014efca68d7731f322604
/app/src/main/java/com/example/user/swipebackactivity/Helper/RecyclerItemTouchHelperListener.java
f17f9890cb98d1ecb9739bfc3473daaf63a4a002
[]
no_license
skbipulr/SwipeBackActivityP
493de95624bbcb86c303ec95e82291fef59d69b7
3fca38858a1bd63d02596bfe96d7d2aed5d1edb0
refs/heads/master
2020-04-09T04:57:44.743989
2018-11-30T17:40:09
2018-11-30T17:40:09
160,044,924
1
0
null
null
null
null
UTF-8
Java
false
false
275
java
package com.example.user.swipebackactivity.Helper; import android.support.v7.widget.RecyclerView; import android.widget.RelativeLayout; public interface RecyclerItemTouchHelperListener { void onSwiped(RecyclerView.ViewHolder viewHolder,int direction,int position); }
6a2a066b1ee881b67d5446071dbb3672b778a216
3764d263cbd3a842f902e00102a295e2eaca245b
/src/com/landptf/controls/ButtonM.java
cde58175604bc79990439a45766e083e47a9eaf3
[]
no_license
877898444/Landptf
530f48ae4a3d94508f2bc2753f19c465889b9684
8f3f532873786ec8686e8d7839801519423c9d4f
refs/heads/master
2021-01-24T11:45:24.741218
2016-05-15T02:06:42
2016-05-15T02:06:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,708
java
package com.landptf.controls; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.widget.Button; /** * 重写Button,自定义Button样式 * @author landptf * @date 2015-6-8 */ public class ButtonM extends Button{ private GradientDrawable gradientDrawable;//控件的样式 private String backColors = "";//背景色,String类型 private int backColori = 0;//背景色,int类型 private String backColorSelecteds = "";//按下后的背景色,String类型 private int backColorSelectedi = 0;//按下后的背景色,int类型 private int backGroundImage = 0;//背景图,只提供了Id private int backGroundImageSeleted = 0;//按下后的背景图,只提供了Id private String textColors = "";//文字颜色,String类型 private int textColori = 0;//文字颜色,int类型 private String textColorSeleteds = "";//按下后的文字颜色,String类型 private int textColorSeletedi = 0;//按下后的文字颜色,int类型 private float radius = 8;//圆角半径 private int shape = 0;//圆角样式,矩形、圆形等,由于矩形的Id为0,默认为矩形 private Boolean fillet = false;//是否设置圆角 public ButtonM(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } public ButtonM(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ButtonM(Context context) { this(context, null); } private void init() { //将Button的默认背景色改为透明,本人不喜欢原来的颜色 if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.TRANSPARENT); }else { setBackgroundColor(Color.TRANSPARENT); } //设置文字默认居中 setGravity(Gravity.CENTER); //设置Touch事件 setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { //按下改变样式 setColor(event.getAction()); //此处设置为false,防止Click事件被屏蔽 return false; } }); } //改变样式 private void setColor(int state){ if (state == MotionEvent.ACTION_DOWN) { //按下 if (backColorSelectedi != 0) { //先判断是否设置了按下后的背景色int型 if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(backColorSelectedi); }else { setBackgroundColor(backColorSelectedi); } }else if (!backColorSelecteds.equals("")) { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.parseColor(backColorSelecteds)); }else { setBackgroundColor(Color.parseColor(backColorSelecteds)); } } //判断是否设置了按下后文字的颜色 if (textColorSeletedi != 0) { setTextColor(textColorSeletedi); }else if (!textColorSeleteds.equals("")) { setTextColor(Color.parseColor(textColorSeleteds)); } //判断是否设置了按下后的背景图 if (backGroundImageSeleted != 0) { setBackgroundResource(backGroundImageSeleted); } } if (state == MotionEvent.ACTION_UP) { //抬起 if (backColori == 0 && backColors.equals("")) { //如果没有设置背景色,默认改为透明 if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.TRANSPARENT); }else { setBackgroundColor(Color.TRANSPARENT); } }else if(backColori != 0){ if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(backColori); }else { setBackgroundColor(backColori); } }else { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.parseColor(backColors)); }else { setBackgroundColor(Color.parseColor(backColors)); } } //如果为设置字体颜色,默认为黑色 if (textColori == 0 && textColors.equals("")) { setTextColor(Color.BLACK); }else if (textColori != 0) { setTextColor(textColori); }else { setTextColor(Color.parseColor(textColors)); } if (backGroundImage != 0) { setBackgroundResource(backGroundImage); } } if(fillet){ setBackgroundDrawable(gradientDrawable); } } /** * 设置按钮的背景色,如果未设置则默认为透明 * @param backColor */ public void setBackColor(String backColor) { this.backColors = backColor; if (backColor.equals("")) { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.TRANSPARENT); }else { setBackgroundColor(Color.TRANSPARENT); } }else { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.parseColor(backColor)); }else { setBackgroundColor(Color.parseColor(backColor)); } } if(fillet){ setBackgroundDrawable(gradientDrawable); } } /** * 设置按钮的背景色,如果未设置则默认为透明 * @param backColor */ public void setBackColor(int backColor) { this.backColori = backColor; if (backColori == 0) { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(Color.TRANSPARENT); }else { setBackgroundColor(Color.TRANSPARENT); } }else { if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setColor(backColor); }else { setBackgroundColor(backColor); } } if(fillet){ setBackgroundDrawable(gradientDrawable); } } /** * 设置按钮按下后的颜色 * @param backColorSelected */ public void setBackColorSelected(int backColorSelected) { this.backColorSelectedi = backColorSelected; } /** * 设置按钮按下后的颜色 * @param backColorSelected */ public void setBackColorSelected(String backColorSelected) { this.backColorSelecteds = backColorSelected; } /** * 设置按钮的背景图 * @param backGroundImage */ public void setBackGroundImage(int backGroundImage) { this.backGroundImage = backGroundImage; if (backGroundImage != 0) { setBackgroundResource(backGroundImage); } } /** * 设置按钮按下的背景图 * @param backGroundImageSeleted */ public void setBackGroundImageSeleted(int backGroundImageSeleted) { this.backGroundImageSeleted = backGroundImageSeleted; } /** * 设置按钮圆角半径大小 * @param radius */ public void setRadius(float radius) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } gradientDrawable.setCornerRadius(radius); setBackgroundDrawable(gradientDrawable); } /** * 设置按钮文字颜色 * @param textColor */ public void setTextColors(String textColor) { this.textColors = textColor; setTextColor(Color.parseColor(textColor)); } /** * 设置按钮文字颜色 * @param textColor */ public void setTextColori(int textColor) { this.textColori = textColor; setTextColor(textColor); } /** * 设置按钮按下的文字颜色 * @param textColor */ public void setTextColorSelected(String textColor) { this.textColorSeleteds = textColor; } /** * 设置按钮按下的文字颜色 * @param textColor */ public void setTextColorSelected(int textColor) { this.textColorSeletedi = textColor; } /** * 按钮的形状 * @param shape */ public void setShape(int shape) { this.shape = shape; } /** * 设置其是否为圆角 * @param fillet */ public void setFillet(Boolean fillet) { this.fillet = fillet; if (fillet) { if (gradientDrawable == null) { gradientDrawable = new GradientDrawable(); } //GradientDrawable.RECTANGLE gradientDrawable.setShape(shape); gradientDrawable.setCornerRadius(radius); setBackgroundDrawable(gradientDrawable); } } }
57e29f50f758e64db03ff136b41f800a2585df58
6d9615c5461b04b488f6c40a07bb5b4ce56d0ad8
/BellHomeWork/src/main/java/com/demo/project/view/office/OfficeByOrgOutView.java
d85bc8c3553d2ce7cd7de3d88db331df891ee317
[]
no_license
IgorVooDoo/bell
ca1b1671a787187c55fed1bad498854c49ba139e
67640f6fa212513205525bd5dbf885bfe9b38de4
refs/heads/master
2020-04-07T15:12:17.132286
2019-03-12T04:51:32
2019-03-12T04:51:32
158,475,619
0
0
null
null
null
null
UTF-8
Java
false
false
523
java
package com.demo.project.view.office; import javax.validation.constraints.NotEmpty; /** * Представление данных объекта Office * для POST-запроса api/office/list (фильтр по ИД организации) * * @see com.demo.project.controller.OfficeController */ public class OfficeByOrgOutView { @NotEmpty public int id; public String name; public boolean isActive; public String toString() { return "{id:" + id + ";name:" + name + ";}"; } }
eec2554974cde3d5293d6bd5957baca86b6b4eb7
48b4a5ec869d6218f48ce2834833380a103fbb24
/app/src/main/java/com/example/chatapp/ui/tools/ToolsViewModel.java
eb8b87256c21f2d94a8e6fcd50dcb9440fa7055e
[]
no_license
Sumit9896926322/Messenger
98109c187a27b3adf9e662f74258c6e6cbeeeb3a
535ebba757bec9114d8c26a4994f4a414c806170
refs/heads/master
2022-07-28T19:09:42.407821
2020-05-17T08:39:43
2020-05-17T08:39:43
262,393,786
1
0
null
null
null
null
UTF-8
Java
false
false
446
java
package com.example.chatapp.ui.tools; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; public class ToolsViewModel extends ViewModel { private MutableLiveData<String> mText; public ToolsViewModel() { mText = new MutableLiveData<>(); mText.setValue("This is tools fragment"); } public LiveData<String> getText() { return mText; } }
a99ae452f9ae973381923d5889ed9028bbc03719
c6c1a124eb1ff2fc561213d43d093f84d1ab2c43
/games/crazy/server/gate/src/main/java/cn/javaplus/crazy/base/GateCollectionFactory.java
375c1a58711f9deee5a1db3e342392eb1f6db622
[]
no_license
fantasylincen/javaplus
69201dba21af0973dfb224c53b749a3c0440317e
36fc370b03afe952a96776927452b6d430b55efd
refs/heads/master
2016-09-06T01:55:33.244591
2015-08-15T12:15:51
2015-08-15T12:15:51
15,601,930
3
1
null
null
null
null
UTF-8
Java
false
false
558
java
package cn.javaplus.crazy.base; import cn.javaplus.crazy.config.Node; import cn.javaplus.crazy.config.ServerJson; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.Mongo; public class GateCollectionFactory { public static final DBCollection getCollection(String name) { Node node = ServerJson.getRoot(); node = node.get("gate").get("mongoDb"); String mongoDBName = node.getString("name"); Mongo m = GateMongoFactory.getMongo(); DB db = m.getDB(mongoDBName); return db.getCollection(name); } }
[ "12-2" ]
12-2
f1ae9968acb23d4a02a2aef88b6f02dc71995227
c61881bea80ef42866c59ee80b3e8ca93e4be379
/app/src/main/java/com/example/weatherapp/model/ForecastRequest.java
1a693c73c9123bb90e3e30b42393adc3f01916f5
[]
no_license
romzhel/WeatherApp
50e4b4c4cf3bac8d709e3b1bd1b5aa38ee8faf7b
2b05a88e179ed9b0e75df50a5553956e25625e78
refs/heads/master
2020-06-09T07:24:31.156405
2019-06-26T20:44:36
2019-06-26T20:44:36
193,399,614
0
0
null
2019-06-26T20:49:22
2019-06-23T22:02:57
Java
UTF-8
Java
false
false
1,190
java
package com.example.weatherapp.model; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; public class ForecastRequest { @SerializedName("code") @Expose private String code; @SerializedName("message") @Expose private double message; @SerializedName("cnt") @Expose private int cnt; @SerializedName("list") @Expose private Forecast[] forecasts; @SerializedName("city") @Expose private City city; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public double getMessage() { return message; } public void setMessage(double message) { this.message = message; } public int getCnt() { return cnt; } public void setCnt(int cnt) { this.cnt = cnt; } public Forecast[] getForecasts() { return forecasts; } public void setForecasts(Forecast[] forecasts) { this.forecasts = forecasts; } public City getCity() { return city; } public void setCity(City city) { this.city = city; } }
59c507fa59db72ed3e0ab22025f275acec8d9061
e1605025638101167b5065321c0b002719224afe
/app/src/main/java/com/xpple/fruits/me/ui/UpdateNicknameActivity.java
2ad4a895db812926d3f466d76fc4be0e27754b0a
[]
no_license
SengarWu/MrFruit
5f02168d0752167c835a4fdde215b8e3331b0726
da1ebf467257ebb4648807d51ddc7256ece367ed
refs/heads/master
2020-06-27T06:50:23.795091
2016-11-23T08:08:49
2016-11-23T08:08:49
74,537,593
0
0
null
null
null
null
UTF-8
Java
false
false
1,288
java
package com.xpple.fruits.me.ui; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; import com.xpple.fruits.R; import com.xpple.fruits.base.BaseActivity; public class UpdateNicknameActivity extends BaseActivity implements View.OnClickListener { private ImageButton ib_back; private EditText et_update_nickname; private TextView tv_update_nickname_finish; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_update_nickname); initView(); } private void initView() { ib_back = $(R.id.ib_back); ib_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); et_update_nickname=$(R.id.et_update_nickname); et_update_nickname.setOnClickListener(this); tv_update_nickname_finish=$(R.id.tv_update_nickname_finish); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.et_update_nickname://修改昵称后点击完成 break; } } }
d80754d3b1062741166c4a2adf2a2b600cae89d9
f4d67892b0663091759130e14abc38eacb3a8a7d
/org.celllife.communicate.webtest/src/test/java/org/celllife/communicate/page/GroupsPage.java
2fd4e75c1fc376a5ed6d79b1ada4f9c28a53482e
[]
no_license
cell-life/communicate
6ab6f86a62866213fc2a5057f83d6c3e0cf3db9a
454de8d9823fb8d5170987ab72a732b7353fe9ec
refs/heads/master
2021-05-02T02:07:32.558672
2018-02-09T19:19:28
2018-02-09T19:19:28
120,880,101
0
1
null
null
null
null
UTF-8
Java
false
false
712
java
package org.celllife.communicate.page; import org.celllife.mobilisr.domain.ContactGroup; public class GroupsPage extends EntityListPage { public GroupsPage(BasePage previousPage) { super(previousPage, "My Groups", "groups-"); } public GroupAddPage goCreatePage() { log.info("Navigate to Add New Groups page"); clickElementById("newGroupButton"); return new GroupAddPage(this); } public GroupsPage deleteGroup(ContactGroup contactGroup) { try { clickElementById("deletebutton-"+contactGroup.getId()); } catch (org.openqa.selenium.ElementNotVisibleException e) { clickExpandMenuItemByText("group-"+contactGroup.getId(), "Delete Group"); } return this; } }
72ab84aab2c8a90024ab178120ecb06ded6592c4
8b88112188e9e6228a806167d4bbbb6410309352
/app/src/main/java/co/com/etn/mvp_base/views/activities/ProductActivity.java
28f7340a59eff1ec78df593fe1f432a3da12c73e
[]
no_license
amalocu/MVP_Base
7a3c8e667ec856f608013784017f59819dbf4444
15b25d791b58576fb910c449190239e2e888f7ec
refs/heads/master
2021-08-08T22:27:13.038399
2017-11-11T12:25:51
2017-11-11T12:25:51
104,568,195
0
0
null
null
null
null
UTF-8
Java
false
false
3,197
java
package co.com.etn.mvp_base.views.activities; import android.animation.Animator; import android.content.Intent; import android.os.Bundle; import android.provider.SyncStateContract; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.view.View; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.widget.AdapterView; import android.widget.ListView; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import co.com.etn.mvp_base.R; import co.com.etn.mvp_base.helper.Constants; import co.com.etn.mvp_base.models.Products; import co.com.etn.mvp_base.presenter.ProductsPresenter; import co.com.etn.mvp_base.views.BaseActivity; import co.com.etn.mvp_base.views.adapter.ProductAdapter; /** * Created by alexander.vasquez on 16/09/2017. */ public class ProductActivity extends BaseActivity<ProductsPresenter> implements IProductView{ private ListView activity_product_list_view; private ProductAdapter productAdapter; private FloatingActionButton activity_product_fab; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_produts); setPresenter(new ProductsPresenter()); activity_product_list_view = (ListView)findViewById(R.id.activity_product_list_view); createProgress(); getPresenter().inject(this, getValidateItnernet()); getPresenter().validateItnernet(); activity_product_fab = (FloatingActionButton)findViewById(R.id.activity_products_fab); activity_product_fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ProductActivity.this, CreateActivity.class); startActivity(intent); } }); } @Override protected void onRestart() { super.onRestart(); getPresenter().validateItnernet(); } @Override protected void onResume() { super.onResume(); //progress.show(); getPresenter().validateItnernet(); } @Override public void showProductsList(final ArrayList<Products> productos) { runOnUiThread(new Runnable() { @Override public void run() { callAdapter(productos); } }); } private void callAdapter(final ArrayList<Products> productos) { productAdapter = new ProductAdapter(this, R.layout.product_layout_item, productos); activity_product_list_view.setAdapter(productAdapter); activity_product_list_view.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(ProductActivity.this,DetailActivity.class); intent.putExtra(Constants.ITEM_PRODUCT, (Products)productos.get(position)); startActivity(intent); } }); } }
c4f66391b0482483e5dcfd57c48611e28fc42827
9b3a52b51cae2bd278492bdec1db483f632cbd73
/app/src/main/java/id/urbanwash/wozapp/fcm/AppFcmListenerService.java
94108e9124d83af35259582dcbba1b4ca251afb1
[]
no_license
enggarmanah/WozApp
df8b2d5314168d09f44b7cfabd4a16af088f554e
d6bdc37e303cf84a184fe21a591a6967c2a35dfc
refs/heads/master
2021-01-11T02:29:01.383288
2017-07-02T04:03:12
2017-07-02T04:03:12
70,964,233
0
0
null
null
null
null
UTF-8
Java
false
false
2,747
java
/** * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package id.urbanwash.wozapp.fcm; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import java.util.Date; import java.util.Map; import id.urbanwash.wozapp.Constant; import id.urbanwash.wozapp.R; import id.urbanwash.wozapp.activity.MainActivity; import id.urbanwash.wozapp.util.CommonUtil; import id.urbanwash.wozapp.util.PushNotificationUtil; public class AppFcmListenerService extends FirebaseMessagingService { private static final String TAG = "AppFcmListenerService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { String from = remoteMessage.getFrom(); Map data = remoteMessage.getData(); String message = CommonUtil.formatString(data.get(Constant.FCM_PARAM_MESSAGE)); String orderNo = CommonUtil.formatString(data.get(Constant.FCM_PARAM_ORDER_NO)); String orderStatus = CommonUtil.formatString(data.get(Constant.FCM_PARAM_ORDER_STATUS)); Date orderDate = null; if (data.get(Constant.FCM_PARAM_ORDER_DATE) != null) { orderDate = new Date(Long.valueOf((String) data.get(Constant.FCM_PARAM_ORDER_DATE))); } String orderPlaceName = CommonUtil.formatString(data.get(Constant.FCM_PARAM_ORDER_PLACE_NAME)); String orderPlaceAddress = CommonUtil.formatString(data.get(Constant.FCM_PARAM_ORDER_PLACE_ADDRESS)); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); PushNotificationUtil.setContext(getApplicationContext()); if (!CommonUtil.isEmpty(message)) { PushNotificationUtil.createNotification(message); } else if (!CommonUtil.isEmpty(orderNo)) { PushNotificationUtil.createNotification(orderNo, orderStatus, orderDate, orderPlaceName, orderPlaceAddress); } } }
ec43bdf9990557dd87db04ae6aa6630925bf3554
3f169749adceb8a84803c561467e391ef381d7d0
/workspace/transaction/src/persistence/CommandCoordinatorFacade.java
3d9166af0f736c806c7d4cdc2494972e308f9f38
[]
no_license
Cryzas/FHDW2
969619012ad05f455d04dce0f3413f53cedd9351
8bc31d4072cc9ed7ddf86154cdf08f0f9a55454b
refs/heads/master
2021-01-23T05:25:00.249669
2017-10-11T06:24:17
2017-10-11T06:24:17
86,296,546
3
0
null
null
null
null
UTF-8
Java
false
false
1,778
java
package persistence; import model.meta.*; public class CommandCoordinatorFacade{ static private Long sequencer = new Long(0); static protected long getTheNextId(){ long result = -1; synchronized (sequencer) { result = sequencer.longValue() + 1; sequencer = new Long(result); } return result; } protected long getNextId(){ return getTheNextId(); } public CommandCoordinatorFacade() { } public PersistentCommandCoordinator getTheCommandCoordinator() throws PersistenceException { long id = ConnectionHandler.getTheConnectionHandler().theCommandCoordinatorFacade.getNextId(); CommandCoordinator result = new CommandCoordinator(id); PersistentInCacheProxi cached = Cache.getTheCache().putSingleton(result); return (PersistentCommandCoordinator)PersistentProxi.createProxi(cached.getId() * (cached.getTheObject().isTheSameAs(result) ? -1 : 1), -101); } public CommandCoordinator getCommandCoordinator(long CommandCoordinatorId) throws PersistenceException{ return null; //All data is in the cache! } public long getClass(long objectId) throws PersistenceException{ if(Cache.getTheCache().contains(objectId, -101)) return -101; throw new PersistenceException("No such object: " + new Long(objectId).toString(), 0); } public long executerAdd(long CommandCoordinatorId, CommandExecuter4Public executerVal) throws PersistenceException { return 0; } public void executerRem(long executerId) throws PersistenceException { } public CommandExecuterList executerGet(long CommandCoordinatorId) throws PersistenceException { return new CommandExecuterList(); // remote access for initialization only! } }
317e4d3b69352bf4551ecd692c63ef345316d556
fb9488e779c8f20d912bcf9d12b904895e46b7d0
/src/PaooGame/Tiles/Lvl2/Pam/Pam6_nesolTile.java
194985cf86af55d0c08b4283077f449f193e4217
[]
no_license
ddfhky/Project-PAOO
edbc3a6eedee2727903b02204f99cda68a33c330
38fb41c408d9233df718714fb08921bbfa2c99f1
refs/heads/master
2023-08-10T01:50:57.658300
2021-09-20T19:20:55
2021-09-20T19:20:55
408,581,692
0
0
null
null
null
null
UTF-8
Java
false
false
606
java
package PaooGame.Tiles.Lvl2.Pam; import PaooGame.Graphics.Assets; import PaooGame.Tiles.Tile; /*! \class public class GrassTile extends Tile \brief Abstractizeaza notiunea de dala de tip iarba. */ public class Pam6_nesolTile extends Tile { /*! \fn public GrassTile(int id) \brief Constructorul de initializare al clasei \param id Id-ul dalei util in desenarea hartii. */ public Pam6_nesolTile(int id) { /// Apel al constructorului clasei de baza super(Assets.pam6_nesol, id); } public boolean IsSolid() { return false; } }
15eadbb2f2087827f9017f8fa0a5105945b0cfd7
9c33e8f55bc62067333d9a94fedd110ad5a9a836
/Pieces.java
24023080e534346196213174752c76807ff27ed4
[]
no_license
mirdaki/CNT4007_Project
57218e2123de5a4b41f8eae50de63e4e0c55c8b9
7e64df36c1cf26c4feb6907fafa39f1d264cb093
refs/heads/master
2021-06-08T15:42:15.071000
2016-12-08T00:27:52
2016-12-08T00:27:52
null
0
0
null
null
null
null
UTF-8
Java
false
false
474
java
/* This class is just used to contain the byteStream for each piece along with an integer representing the "index" of the piece relative to the other pieces */ public class Pieces { private int pieceIndex; private byte[] pieceBytes; public Pieces(int pieceIndex, byte[] pieceBytes) { this.pieceIndex = pieceIndex; this.pieceBytes = pieceBytes; } public byte[] getPieceBytes() { return pieceBytes; } public int getPieceIndex() { return pieceIndex; } }
eb997b22acb3811f0f2ff7444dd6560351c50151
87216dbafc517d2fc07490877f6a752c9bf36ccd
/src/main/java/mf/service/impl/SysUserRoleServiceImpl.java
d99a9798e84699b5289f6ee4724de46dbbd5bcda
[ "Apache-2.0" ]
permissive
Tiger-weichat/mfv2
f08e3f4d52ca3f9680b99ed7429ecaa7526bf4ec
d800daa896d7df4abd17da3d60972b7f02bd2e58
refs/heads/master
2021-01-01T18:38:44.901945
2017-07-28T08:29:35
2017-07-28T08:29:35
98,387,298
0
1
null
null
null
null
UTF-8
Java
false
false
1,134
java
package mf.service.impl; import mf.dao.SysUserRoleDao; import mf.service.SysUserRoleService; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * 用户与角色对应关系 * * @author chenshun * @email [email protected] * @date 2016年9月18日 上午9:45:48 */ @Service("sysUserRoleService") public class SysUserRoleServiceImpl implements SysUserRoleService { @Autowired private SysUserRoleDao sysUserRoleDao; @Override public void saveOrUpdate(Long userId, List<Long> roleIdList) { if(roleIdList.size() == 0){ return ; } //先删除用户与角色关系 sysUserRoleDao.delete(userId); //保存用户与角色关系 Map<String, Object> map = new HashMap<>(); map.put("userId", userId); map.put("roleIdList", roleIdList); sysUserRoleDao.save(map); } @Override public List<Long> queryRoleIdList(Long userId) { return sysUserRoleDao.queryRoleIdList(userId); } @Override public void delete(Long userId) { sysUserRoleDao.delete(userId); } }
29b529218227f41de744fe446a48b45d32c6f72a
d6cf28d1b37216c657d23d8e512c15bdd9d3f226
/dependencies/api-sdk/src/main/java/com/foreveross/atwork/api/sdk/Employee/responseModel/QueryEmployeeResponseJson.java
34dafca7420d17a778bb89ad78a5a84e840c615a
[ "MIT" ]
permissive
AoEiuV020/w6s_lite_android
a2ec1ca8acdc848592266b548b9ac6b9a4117cd3
1c4ca5bdaea6d5230d851fb008cf2578a23b2ce5
refs/heads/master
2023-08-22T00:46:03.054115
2021-10-27T06:21:32
2021-10-27T07:45:41
421,650,297
1
0
null
null
null
null
UTF-8
Java
false
false
408
java
package com.foreveross.atwork.api.sdk.Employee.responseModel; import com.foreveross.atwork.api.sdk.model.BasicResponseJSON; import com.foreveross.atwork.infrastructure.model.Employee; import com.google.gson.annotations.SerializedName; /** * Created by dasunsy on 16/6/15. */ public class QueryEmployeeResponseJson extends BasicResponseJSON{ @SerializedName("result") public Employee mEmployee; }
cc5a2074a5faf6d0997d8f79edc43574e4841c1c
c3d086357565983997d3d4c1c6890266e5607c97
/data/jrdf/jrdf-0.3.4/org/jrdf/graph/mem/MemNode.java
6ede25999f55c3acf17993ff23a1de8b13676a56
[ "MIT" ]
permissive
hrahmadi71/MultiRefactor
39ab0f4900f27e2b021e48af590f767495f01077
99a15c96d045aa0b798d3d364ecb49153361a5a9
refs/heads/master
2022-11-25T14:27:37.678256
2020-07-27T02:58:13
2020-07-27T02:58:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,236
java
/* * $Header: /cvsroot/jrdf/jrdf/src/org/jrdf/graph/mem/Attic/MemNode.java,v 1.6 2005/06/21 20:53:03 newmana Exp $ * $Revision: 1.6 $ * $Date: 2005/06/21 20:53:03 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The JRDF Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * the JRDF Project (http://jrdf.sf.net/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The JRDF Project" and "JRDF" must not be used to endorse * or promote products derived from this software without prior written * permission. For written permission, please contact * [email protected]. * * 5. Products derived from this software may not be called "JRDF" * nor may "JRDF" appear in their names without prior written * permission of the JRDF Project. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the JRDF Project. For more * information on JRDF, please see <http://jrdf.sourceforge.net/>. */ package org.jrdf.graph.mem; import java.io.Serializable; /** * Memory node. This is an additional interface for nodes so they can be accessed by id. * Extends {@link Serializable} so all nodes will be serializable. * * @author <a href="mailto:[email protected]">Paul Gearon</a> * * @version $Revision: 1.6 $ */ public interface MemNode extends Serializable { /** * Retrieves an internal identifier for a node. * * @return A numeric identifier for a node. */ Long getId(); }
2391c1e8997b10cb90aaefb52d4860cf1336a7e9
cba543b732a9a5ad73ddb2e9b20125159f0e1b2e
/sikuli_ide/src/main/java/org/app/co/jp/cmp/CustomerPatternPaneNaming.java
7af28ab833b06d841034146dafe8837891fab9ab
[]
no_license
wsh231314/IntelligentOperation
e6266e1ae79fe93f132d8900ee484a4db0da3b24
a12aca5c5c67e6a2dddcd2d8420ca8a64af476f2
refs/heads/master
2020-04-05T13:31:55.376669
2017-07-28T05:59:05
2017-07-28T05:59:05
94,863,918
1
2
null
2017-07-27T02:44:17
2017-06-20T07:45:10
Java
UTF-8
Java
false
false
7,058
java
/* * Copyright (c) 2010-2016, Sikuli.org, sikulix.com * Released under the MIT License. * */ package org.app.co.jp.cmp; import org.sikuli.basics.Debug; import org.sikuli.basics.PreferencesUser; import org.sikuli.ide.SikuliIDEI18N; import org.sikuli.script.TextRecognizer; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.io.File; //RaiMan not used import org.sikuli.script.TextRecognizer; public class CustomerPatternPaneNaming extends JPanel { final static int TXT_FILE_EXT_LENGTH = 4; final static int TXT_FILENAME_LENGTH = 20; final static int MAX_OCR_TEXT_LENGTH = 12; final static int THUMB_MAX_HEIGHT = 200; CustomerImageButton _imgBtn; JTextField _txtPath, _txtFileExt; JComboBox _txtFilename; String _oldFilename; static String _I(String key, Object... args) { return SikuliIDEI18N._I(key, args); } public CustomerPatternPaneNaming(CustomerImageButton imgBtn, JLabel msgApplied) { super(new GridBagLayout()); init(imgBtn, msgApplied); } private void init(CustomerImageButton imgBtn, JLabel msgApplied) { _imgBtn = imgBtn; JLabel lblPath = new JLabel(_I("lblPath")); JLabel lblFilename = new JLabel(_I("lblFilename")); String filename = _imgBtn.getFilename(); File f = new File(filename); String fullpath = f.getParent(); filename = getFilenameWithoutExt(f); _oldFilename = filename; BufferedImage thumb = _imgBtn.createThumbnailImage(THUMB_MAX_HEIGHT); Border border = LineBorder.createGrayLineBorder(); JLabel lblThumb = new JLabel(new ImageIcon(thumb)); lblThumb.setBorder(border); _txtPath = new JTextField(fullpath, TXT_FILENAME_LENGTH); _txtPath.setEditable(false); _txtPath.setEnabled(false); String[] candidates = new String[]{filename}; //<editor-fold defaultstate="collapsed" desc="OCR --- not used"> /* String ocrText = getFilenameFromImage(thumb); if(ocrText.length()>0 && !ocrText.equals(filename)) candidates = new String[] {filename, ocrText}; */ //</editor-fold> _txtFilename = new AutoCompleteCombo(candidates); _txtFileExt = new JTextField(getFileExt(f), TXT_FILE_EXT_LENGTH); _txtFileExt.setEditable(false); _txtFileExt.setEnabled(false); GridBagConstraints c = new GridBagConstraints(); c.gridy = 0; c.insets = new Insets(100, 0, 0, 0); this.add(new JLabel(""), c); c = new GridBagConstraints(); c.fill = 0; c.gridwidth = 3; c.gridy = 1; c.insets = new Insets(0, 10, 20, 10); this.add(lblThumb, c); c = new GridBagConstraints(); c.fill = 1; c.gridy = 2; this.add(lblPath, c); c.gridx = 1; c.gridwidth = 2; this.add(_txtPath, c); c = new GridBagConstraints(); c.gridy = 3; c.fill = 0; this.add(lblFilename, c); this.add(_txtFilename, c); this.add(_txtFileExt, c); c = new GridBagConstraints(); c.gridy = 4; c.gridx = 1; c.insets = new Insets(200, 0, 0, 0); this.add(msgApplied, c); } public void updateFilename() { _oldFilename = (String) _txtFilename.getSelectedItem(); } private String getFilenameWithoutExt(File f) { String name = f.getName(); int pos = name.lastIndexOf('.'); if (pos > 0) { return name.substring(0, pos); } return name; } private String getFileExt(File f) { String name = f.getName(); int pos = name.lastIndexOf('.'); if (pos > 0) { return name.substring(pos); } return ""; } public static String getFilenameFromImage(BufferedImage img) { TextRecognizer tr = TextRecognizer.getInstance(); if (!PreferencesUser.getInstance().getPrefMoreTextOCR() || tr == null) { return ""; } String text = tr.recognize(img); text = text.replaceAll("\\W", ""); if (text.length() > MAX_OCR_TEXT_LENGTH) { return text.substring(0, MAX_OCR_TEXT_LENGTH); } return text; } public String getAbsolutePath() { return _txtPath.getText() + File.separatorChar + _txtFilename.getSelectedItem() + _txtFileExt.getText(); } public boolean isDirty() { String newFilename = (String) _txtFilename.getSelectedItem(); return !_oldFilename.equals(newFilename); } } class AutoCompleteCombo extends JComboBox { private static final String me = "PatternPaneNaming: "; final static int TXT_FILENAME_LENGTH = 20; public int caretPos = 0; public JTextField editor = null; public AutoCompleteCombo(final Object items[]) { super(items); this.setEditable(true); setHook(); //hideDropDownButton(); } private void hideDropDownButton() { for (Component component : this.getComponents()) { if (component instanceof AbstractButton && component.isVisible()) { component.setVisible(false); this.revalidate(); } } } @Override public void setSelectedIndex(int ind) { super.setSelectedIndex(ind); editor.setText(getItemAt(ind).toString()); editor.setSelectionEnd(caretPos + editor.getText().length()); editor.moveCaretPosition(caretPos); } public void setHook() { ComboBoxEditor anEditor = this.getEditor(); if (anEditor.getEditorComponent() instanceof JTextField) { editor = (JTextField) anEditor.getEditorComponent(); editor.setColumns(TXT_FILENAME_LENGTH); editor.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ev) { char key = ev.getKeyChar(); if (!(Character.isLetterOrDigit(key) || Character .isSpaceChar(key))) { return; } caretPos = editor.getCaretPosition(); String text = ""; try { text = editor.getText(0, caretPos); } catch (Exception ex) { Debug.error(me + "setHook: Problem getting image file name\n%s", ex.getMessage()); } int n = getItemCount(); for (int i = 0; i < n; i++) { int ind = ((String) getItemAt(i)).indexOf(text); if (ind == 0) { setSelectedIndex(i); return; } } } }); } } }
fcf69c6761af5069b98ad14e54c6277e743222b1
bc5ef75fe7234fb32cb3a4100bf31227232909c5
/src/main/java/configuration/ConfigApp.java
39b75bb0fa0ba30c5ef35d0b8887bc6b567de6b6
[]
no_license
polina606257/AnnouncementCatalogData
e5812378bb2b556506e9009296d8e4df0d2c3f77
125f4d081c0cccacdad29e2f863acd82ee71295a
refs/heads/master
2021-01-07T15:26:17.741880
2020-02-19T23:07:04
2020-02-19T23:07:04
241,741,564
0
0
null
null
null
null
UTF-8
Java
false
false
6,485
java
package configuration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor; import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import java.util.Properties; /** * Class ConfigAppTest set up all the configurations, makes connection with database, manages transactions and defines * strategy for sending emails * @author Polina Shcherbinina * @version 1.1 */ @Configuration @ComponentScan(basePackages = {"controller", "service"}) @EnableWebMvc @EnableTransactionManagement @EnableAspectJAutoProxy(proxyTargetClass = true) @EnableJpaRepositories(basePackages = "repository") @EnableScheduling public class ConfigApp implements WebMvcConfigurer { /** * Method binds a JPA EntityManager from the specified factory to the thread, potentially allowing for one * thread-bound EntityManager per factory. This transaction manager is appropriate for applications that use a single * JPA EntityManagerFactory for transactional data access. It helps to open and close transactions * @param emfb EntityManagerFactory provides an efficient way to construct multiple EntityManager instances for a * database. * @return JPATransactionalManager that is responsible for transactional data access */ @Bean public PlatformTransactionManager transactionManager(EntityManagerFactory emfb) { JpaTransactionManager manager = new JpaTransactionManager(); manager.setEntityManagerFactory(emfb); manager.setDataSource(dataSource()); return manager; } /** * Method sets up a location where data that is being used originates from * @return DataSource is the location where data that is being used originates from. */ @Bean public DataSource dataSource() { DriverManagerDataSource source = new DriverManagerDataSource(); source.setDriverClassName("com.mysql.cj.jdbc.Driver"); source.setUrl("jdbc:mysql://localhost:3306/ad_catalog?serverTimezone=UTC&useLegacyDatetimeCode=false"); source.setUsername("root"); source.setPassword("123456"); return source; } @Bean /** * Method allows to plug in vendor-specific behavior into Spring's EntityManagerFactory creators. Serves as single * configuration point for all vendor-specific properties * @return JPAVendorAdapter that allows to plug in vendor-specific behavior into Spring's EntityManagerFactory * creators */ public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.MYSQL); adapter.setShowSql(true); adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect"); adapter.setGenerateDdl(true); return adapter; } /** * Method produces a container-managed EntityManagerFactory * @param adapter JPAVendorAdapter * @param dataSource DataSource * @return LocalContainerEntityManagerFactoryBean that supports links to an existing JDBC DataSource, supports both * local and global transactions */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(JpaVendorAdapter adapter, DataSource dataSource) { LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean(); emfb.setDataSource(dataSource); emfb.setJpaVendorAdapter(adapter); emfb.setPackagesToScan("domain"); return emfb; } /** * Method gets PersistenceAnnotationBeanPostProcessor that processes PersistenceUnit and PersistenceContext * annotations, for injection of the corresponding JPA resources EntityManagerFactory and EntityManager * @return PersistenceAnnotationBeanPostProcessor */ @Bean public PersistenceAnnotationBeanPostProcessor processor() { return new PersistenceAnnotationBeanPostProcessor(); } /** * Method allows default servlet to serve the resource * @param configurer DefaultServletHandlerConfigurer is used to serve static resources */ @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); } /** * Method defines a strategy for sending simple mails * @return JavaMailSender that used in conjunction with the MimeMessageHelper class for convenient creation of * JavaMail MimeMessages, including attachments */ @Bean public JavaMailSender mailSender() { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost("smtp.gmail.com"); sender.setPort(587); sender.setUsername("[email protected]"); sender.setPassword("Suntour123"); Properties properties = sender.getJavaMailProperties(); properties.put("mail.transport.protocol", "smtp"); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.ssl.trust", "smtp.gmail.com"); properties.put("mail.smtp.starttls.enable", "true"); return sender; } }
0f0ab772b2aff728d9d95038be77198eac035e33
1384067f3b86a03b6e6c6b4495bb1584a8c2b133
/lib/src/main/java/com/xiaojinzi/activityresult/ex/ActivityResultException.java
eef31f6c6a0537aa960233069cbc515ec1c54969
[ "Apache-2.0" ]
permissive
xiaojinzi123/ActivityResultHelper
2aac22688202c09b9704aaf64e5e0f859360293e
f28166323d973238e2946f82487ec3df4837ca5d
refs/heads/master
2021-02-08T00:19:27.736100
2020-03-04T11:20:08
2020-03-04T11:20:08
244,090,414
2
0
null
null
null
null
UTF-8
Java
false
false
523
java
package com.xiaojinzi.activityresult.ex; /** * 表示 Activity result 异常 * * time : 2018/11/03 * * @author : xiaojinzi */ public class ActivityResultException extends RuntimeException { public ActivityResultException() { } public ActivityResultException(String message) { super(message); } public ActivityResultException(String message, Throwable cause) { super(message, cause); } public ActivityResultException(Throwable cause) { super(cause); } }
95ede3c96e2dbc7339357ba6f2e3290d96451b3d
32acaf9208e3470f775c9ac94c2956c9db2cc9f4
/src/main/java/com/generics/interf/SortedPair.java
e0ebd155e71e6adaec657515c206fa857bcb8b67
[]
no_license
alloretPerso/pratcingJava
2a2e1f988ae03220354f3ef7944dca9ecedc4511
db2e89a692c4d0acaa8d63bfe60a638c159c075a
refs/heads/master
2022-03-12T10:29:08.879614
2021-01-16T19:43:43
2021-01-16T19:43:43
242,430,158
1
0
null
2022-01-21T23:40:34
2020-02-23T00:04:10
Java
UTF-8
Java
false
false
475
java
package com.generics.interf; public class SortedPair<T extends Comparable<T>> { private T fist; private T second; public SortedPair(T left, T right) { if (left.compareTo(right) < 0){ this.fist = left; this.second = right; }else { this.fist = right; this.second = left; } } public T getFist() { return fist; } public T getSecond() { return second; } }
920cc1a887da9aa29642bf6e7b8411b4ad2272da
2667d7565e62b04337b93dc34876dfae8cf11b0d
/gmall-sms/src/main/java/com/atguigu/gmall/sms/controller/SkuLadderController.java
f458632ed3c75e7aab9a421d2d2a69203d6a130e
[ "Apache-2.0" ]
permissive
caodan689/gmall-0522
b6dc1813686c0a883a9fcadc628b35fcea80b04c
64b13825aeba6039437a1117f62914bfb8ec5167
refs/heads/main
2023-06-24T16:46:45.532401
2020-11-24T03:33:57
2020-11-24T03:33:57
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,453
java
package com.atguigu.gmall.sms.controller; import java.util.List; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.atguigu.gmall.sms.entity.SkuLadderEntity; import com.atguigu.gmall.sms.service.SkuLadderService; import com.atguigu.gmall.common.bean.PageResultVo; import com.atguigu.gmall.common.bean.ResponseVo; import com.atguigu.gmall.common.bean.PageParamVo; /** * 商品阶梯价格 * * @author fengge * @email [email protected] * @date 2020-10-28 10:02:46 */ @Api(tags = "商品阶梯价格 管理") @RestController @RequestMapping("sms/skuladder") public class SkuLadderController { @Autowired private SkuLadderService skuLadderService; /** * 列表 */ @GetMapping @ApiOperation("分页查询") public ResponseVo<PageResultVo> querySkuLadderByPage(PageParamVo paramVo){ PageResultVo pageResultVo = skuLadderService.queryPage(paramVo); return ResponseVo.ok(pageResultVo); } /** * 信息 */ @GetMapping("{id}") @ApiOperation("详情查询") public ResponseVo<SkuLadderEntity> querySkuLadderById(@PathVariable("id") Long id){ SkuLadderEntity skuLadder = skuLadderService.getById(id); return ResponseVo.ok(skuLadder); } /** * 保存 */ @PostMapping @ApiOperation("保存") public ResponseVo<Object> save(@RequestBody SkuLadderEntity skuLadder){ skuLadderService.save(skuLadder); return ResponseVo.ok(); } /** * 修改 */ @PostMapping("/update") @ApiOperation("修改") public ResponseVo update(@RequestBody SkuLadderEntity skuLadder){ skuLadderService.updateById(skuLadder); return ResponseVo.ok(); } /** * 删除 */ @PostMapping("/delete") @ApiOperation("删除") public ResponseVo delete(@RequestBody List<Long> ids){ skuLadderService.removeByIds(ids); return ResponseVo.ok(); } }
7d9be2db812671f20974dc4a76c131a9095de34d
231127718b967565f46520ed43a7a1616e875f41
/app/src/main/java/com/example/xieyo/roam/service/PlayService.java
659727fb00a3eb39960b23e69fb78c21e5ba1e06
[]
no_license
yongweixie/Roam
c2a3e75b5e8b6e0cf5cbae482e337315215d029a
db251c74c0fdeb38c3a7e26f5732a52896cd07f1
refs/heads/master
2020-04-26T15:40:25.915605
2019-11-14T10:16:17
2019-11-14T10:16:17
173,653,884
0
0
null
null
null
null
UTF-8
Java
false
false
7,291
java
package com.example.xieyo.roam.service; import android.app.Service; import android.content.Intent; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.IBinder; import com.example.xieyo.roam.baseinfo.MusicBaseInfo; import java.util.Timer; import java.util.TimerTask; public class PlayService extends Service implements MediaPlayer.OnPreparedListener { // 操作标记 public static final int FLAG_LOAD_PATH = 0;// 加载播放列表 public static final int FLAG_PLAY = 1;// 开始/暂停 public static final int FLAG_PREVIOUS = 2;// 上一首 public static final int FLAG_NEXT = 3;// 下一首 public static final int FLAG_PROGRESS = 4;// 更新进度 public static final int FLAG_PlAY_PAUSE = 5;// public static final int FLAG_MAXPROGRESS = 6;// 最大进度 public static final String ACTION_PROGRESS = "progress_action";// 发送当前进度的广播的动作 public static final String ACTION_MAX = "max_action";// 发送最大进度的广播的动作 public static final String ACTION_MUSIC_STATE = "musicstate_action";//当前正在播放的音乐以及状态,广播出去刷新界面 public static final String ACTION_MUSIC_ID = "musicid_action";//当前正在播放的音乐以及状态,广播出去刷新界面 // 播放列表 private String[] lists; // 媒体播放器 private MediaPlayer player; // private PLMediaPlayer mMediaPlayer = new PLMediaPlayer(this); //PLMediaPlayer mMediaPlayer = new PLMediaPlayer(mContext, mAVOptions); // 当前播放音乐的下角标 private Timer timer; private int Getindex; private int curIndex; public PlayService() { } @Override public IBinder onBind(Intent intent) { return null; } @Override public void onPrepared(MediaPlayer mp) { // TODO Auto-generated method stub mp.start(); sendMaxProgress(); } @Override public void onCreate() { super.onCreate(); // 初始化媒体播放器 player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setOnPreparedListener(this); curIndex= MusicBaseInfo.CurrentMusicIndex; } @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { int flag = intent.getIntExtra("flag", -1); Getindex=intent.getIntExtra("index",-1); switch (flag) { case FLAG_LOAD_PATH:// 加载播放列表 lists = intent.getStringArrayExtra("list"); if (Getindex!=0) { sendCurrentId(); } break; case FLAG_PLAY:// 播放/暂停 // if (player.isPlaying()) { // // 暂停 // player.pause(); // } else { // // 播放 // play(curIndex); // } player.reset(); play(Getindex); curIndex=Getindex; sendCurrentId(); break; case FLAG_PlAY_PAUSE: if (player.isPlaying()) { // 暂停 player.pause(); sendCurrentState(); } else { // 播放 play(curIndex); player.start(); } break; case FLAG_PREVIOUS:// 上一曲 if (curIndex > 0) { // 重置播放器资源 player.reset(); play(--curIndex); } if (curIndex == 0) { // 重置播放器资源 player.reset(); play(curIndex); } sendCurrentId(); break; case FLAG_NEXT:// 下一首 if (curIndex < lists.length - 1) { player.reset(); play(++curIndex); } if (curIndex ==lists.length - 1) { player.reset(); play(curIndex); } sendCurrentId(); break; case FLAG_PROGRESS:// 更新播放进度 int progress = intent.getIntExtra("progress", 0); player.seekTo(progress); break; case FLAG_MAXPROGRESS: sendMaxProgress(); break; } } return super.onStartCommand(intent, flags, startId); } // 播放指定歌曲 private void play(int index) { try { // 设置播放文件的路径 player.setDataSource(lists[index]); // 播放器执行准备工作,获取播放音乐信息,例如音乐长度 // player.prepare(); player.prepareAsync(); // 通知SeekBar设置最大值 } catch (Exception e) { e.printStackTrace(); } // media.prepare(); // 播放音乐 // 音乐播放后,控制SeekBar进度 timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { // 每隔1s发送一次广播,携带当前进度。主界面不断接收到广播,执行SeekBat更新进度的操作 Intent intent = new Intent(ACTION_PROGRESS); intent.putExtra("progress", player.getCurrentPosition());// 获取当前播放进度 sendBroadcast(intent); } }, 0, 100); sendCurrentState(); } // 获取音乐最大进度,并使用广播通知SeekBar private void sendMaxProgress() { Intent intent = new Intent(ACTION_MAX); intent.putExtra("max", player.getDuration());// 每首音乐的完整时间 sendBroadcast(intent); } private void sendCurrentId() { Intent intent = new Intent(ACTION_MUSIC_ID); intent.putExtra("index", curIndex);// 当前播放ID sendBroadcast(intent); } private void sendCurrentState() { //播放状态 timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Intent intent = new Intent(ACTION_MUSIC_STATE); if(player.isPlaying()) { intent.putExtra("state", 1);// } else { intent.putExtra("state", 0);// } sendBroadcast(intent); } }, 0, 300); } @Override public void onDestroy() { if (timer != null) { timer.cancel(); timer = null; } player.stop(); player.release();// 释放资源 } }
e5e77a259697d56e570166ef341e33b1030884ab
199ac802b9ce669feacdad3cbde48f0654387760
/src/main/java/org/jenkinsci/plugins/scriptsecurity/scripts/languages/GroovyXmlLanguage.java
9d3e262a2584fbf0d877b6e8c40befa7387495fa
[]
no_license
carlossg/script-security-plugin
b3079c532a10d4fc33b040be35a907e8e4390c1c
cf27d253b1d6e7150dbd5077988fea7f6621c2ac
refs/heads/master
2020-12-28T20:09:08.682317
2016-04-04T17:40:08
2016-04-04T17:40:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,883
java
/* * The MIT License * * Copyright 2014 CloudBees, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.jenkinsci.plugins.scriptsecurity.scripts.languages; import org.jenkinsci.plugins.scriptsecurity.scripts.Language; import hudson.Extension; import jenkins.model.Jenkins; /** * Language for Groovy Template scripts generating XML. */ @Extension public final class GroovyXmlLanguage extends Language { public static Language get() { return Jenkins.getInstance().getExtensionList(Language.class).get(GroovyXmlLanguage.class); } @Override public String getName() { return "groovy-xml"; } @Override public String getDisplayName() { return "Groovy Template for XML"; } @Override public String getCodeMirrorMode() { return "xml"; // not exactly, but close enough? } }
80319d2fac47ba8ba407e8fb195ef794112ce7b9
39c6a142fe88fcb208feebe457f46b198ab576f1
/ClientChatApp/src/clientchatapp/ClientChat.java
f5888d0e97389a4814f98c0d3e8c4c052f7d47fd
[]
no_license
MNaguib2611/chatApp
d067414cc3cf3743549172fe4f4c8bd68ba214ea
72ef9cb6d66e4d08436d0c265869a1b5c4268cbe
refs/heads/master
2021-01-04T13:46:39.609024
2020-02-14T19:12:44
2020-02-14T19:12:44
240,580,775
0
0
null
null
null
null
UTF-8
Java
false
false
2,671
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package clientchatapp; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.DataInputStream; import java.io.IOException; import java.io.PrintStream; import java.net.Socket; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; /** * * @author migo2 */ class ClientChat extends JFrame{ Socket mySocket; //create an reference of ANormalSocket DataInputStream dis ; //create a stream reference To Recieve PrintStream ps; //create a stream reference of send public ClientChat(){ this.setLayout(new FlowLayout()); JTextArea ta=new JTextArea(20,20); JScrollPane scroll=new JScrollPane(ta); scroll.setViewportView(ta); JTextField tf=new JTextField(30); JButton okButton=new JButton("Send"); okButton.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ae){ String str =tf.getText(); // ta.append(tf.getText()+"\n"); ps.println(str); tf.setText(" "); } }); add(scroll); add(tf); add(okButton); try{ // mySocket = new Socket("192.168.43.229", 7777); //create normal Socket with port 5005 mySocket = new Socket("127.0.0.1", 5006); dis = new DataInputStream(mySocket.getInputStream()); //create the input stream to recieve ps= new PrintStream(mySocket.getOutputStream()); //create the output stream to send }catch(Exception ex){ ex.printStackTrace(); } new Thread(new Runnable(){ @Override public void run(){ while(true){ try { String replyMsg= dis.readLine(); ta.append("\n"+replyMsg); // System.out.println(dis.readLine()); } catch (IOException ex) { ex.printStackTrace(); } } } }).start(); } public static void main(String[] args) { ClientChat client1 =new ClientChat(); client1.setSize(400, 500); client1.setVisible(true); } }
72397cf85c674877bc6a764cd05055e876da3acf
cc3806d1276f7df3062d9a294592d600c21ff3fb
/IBFbNursery/src/ibfb/nursery/persons/SelectLocationPanel.java
26da97578c25b02d080bfa7857c2b5b2d727f71c
[]
no_license
digitalabs/IBFb
7f59be1f87b40d8073e3b2551be1f1228678ccda
12cf95c296c01324489c061b4a161d459312c3ab
refs/heads/master
2021-01-10T21:15:46.823523
2013-12-27T01:59:00
2013-12-27T01:59:00
12,491,100
0
0
null
null
null
null
UTF-8
Java
false
false
26,849
java
package ibfb.nursery.persons; import ibfb.nursery.naming.NamingConvention; import java.util.List; import org.cimmyt.cril.ibwb.api.AppServicesProxy; import org.cimmyt.cril.ibwb.domain.Location; public class SelectLocationPanel extends javax.swing.JPanel { private int currentLocid = 0; private Location currentLocation = new Location(false); private Location currentProvince = new Location(false); List<Location> allLocation = null; List<Location> countryList = null; List<Location> provinceList = null; List<Location> districtList = null; private String namingConvention; private boolean onlyShowInventoryLocations; /** * Creates new form SelectLocationPanel */ public SelectLocationPanel() { namingConvention = NamingConvention.OTHER_CROPS; onlyShowInventoryLocations = false; initComponents(); initAllLocations(); initCountryBox(); } public SelectLocationPanel(boolean onlyShowInventoryLocations) { namingConvention = NamingConvention.OTHER_CROPS; this.onlyShowInventoryLocations = onlyShowInventoryLocations; initComponents(); initAllLocations(); initCountryBox(); assignInventoryLocations(); } public void assignNamingConvention(String namingConvention) { this.namingConvention = namingConvention; if (!namingConvention.equals(NamingConvention.OTHER_CROPS)) { lblDistrict.setVisible(false); cboDistrict.setVisible(false); } } private void assignInventoryLocations() { if (onlyShowInventoryLocations) { lblState.setVisible(false); cboState.setVisible(false); lblDistrict.setVisible(false); cboDistrict.setVisible(false); lblCountry.setText("Storage or Seed stock Location"); } } private void initCountryBox() { Location locationFilter = new Location(true); if (onlyShowInventoryLocations) { locationFilter.setLtype(Location.LTYPE_STORAGE_SEED_STOCK_LOCATION); } else { locationFilter.setLtype(Location.LTYPE_COUNTRY); } locationFilter.setLrplce(0); countryList = AppServicesProxy.getDefault().appServices().getListLocation(locationFilter, 0, 0, false); SortedComboBoxModel cboCountryModel = new SortedComboBoxModel(); for (Location country : countryList) { if (country.getLocid() == 0) { if (onlyShowInventoryLocations) { country.setLname("- Choose Location -"); } else { country.setLname("- Choose Country -"); } } if (!onlyShowInventoryLocations) { if (country.getCntryid().equals(country.getLocid())) { cboCountryModel.addElement(country.getLname()); } } else { cboCountryModel.addElement(country.getLname()); } } cboCountry.setModel(cboCountryModel); if (cboCountry.getItemCount() > 0) { cboCountry.setSelectedIndex(0); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel2 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); chosenLocationIDLabel = new javax.swing.JLabel(); chosenLocationId = new javax.swing.JTextField(); chosenLocation = new javax.swing.JTextField(); chosenLocationLabel = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); lblDistrict = new javax.swing.JLabel(); lblCountry = new javax.swing.JLabel(); cboState = new javax.swing.JComboBox(); cboDistrict = new javax.swing.JComboBox(); cboCountry = new javax.swing.JComboBox(); lblState = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.jPanel1.border.title"))); // NOI18N chosenLocationIDLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); chosenLocationIDLabel.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.chosenLocationIDLabel.text")); // NOI18N chosenLocationId.setEditable(false); chosenLocationId.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.chosenLocationId.text")); // NOI18N chosenLocationId.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chosenLocationIdActionPerformed(evt); } }); chosenLocation.setEditable(false); chosenLocation.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.chosenLocation.text")); // NOI18N chosenLocationLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); chosenLocationLabel.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.chosenLocationLabel.text")); // NOI18N jButton2.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.jButton2.text")); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(32, 32, 32) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(chosenLocationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(chosenLocationIDLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(chosenLocationId, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE) .addComponent(chosenLocation)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2) .addGap(22, 22, 22)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(1, 1, 1) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chosenLocationIDLabel) .addComponent(chosenLocationId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chosenLocationLabel) .addComponent(chosenLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(17, Short.MAX_VALUE)) ); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.jPanel3.border.title"))); // NOI18N lblDistrict.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblDistrict.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.lblDistrict.text")); // NOI18N lblCountry.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblCountry.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.lblCountry.text")); // NOI18N cboState.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cboStateItemStateChanged(evt); } }); cboDistrict.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cboDistrictItemStateChanged(evt); } }); cboCountry.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cboCountryItemStateChanged(evt); } }); lblState.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblState.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.lblState.text")); // NOI18N jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ibfb/nursery/images/location.png"))); // NOI18N jLabel1.setText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.jLabel1.text")); // NOI18N jLabel1.setToolTipText(org.openide.util.NbBundle.getMessage(SelectLocationPanel.class, "SelectLocationPanel.jLabel1.toolTipText")); // NOI18N javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(lblState, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblDistrict, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblCountry, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(cboState, javax.swing.GroupLayout.Alignment.LEADING, 0, 267, Short.MAX_VALUE) .addComponent(cboCountry, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cboDistrict, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addComponent(jLabel1) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cboCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblCountry)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cboState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblState)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cboDistrict, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblDistrict)))) .addGap(12, 12, 12)) ); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void cboCountryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboCountryItemStateChanged countryChange(); }//GEN-LAST:event_cboCountryItemStateChanged private void cboStateItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboStateItemStateChanged stateChange(); }//GEN-LAST:event_cboStateItemStateChanged private void cboDistrictItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDistrictItemStateChanged districtChange(); }//GEN-LAST:event_cboDistrictItemStateChanged private void chosenLocationIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chosenLocationIdActionPerformed getLocationById(); }//GEN-LAST:event_chosenLocationIdActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed clearFields(0); initAllLocations(); initCountryBox(); }//GEN-LAST:event_jButton2ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox cboCountry; private javax.swing.JComboBox cboDistrict; private javax.swing.JComboBox cboState; private javax.swing.JTextField chosenLocation; private javax.swing.JLabel chosenLocationIDLabel; private javax.swing.JTextField chosenLocationId; private javax.swing.JLabel chosenLocationLabel; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JLabel lblCountry; private javax.swing.JLabel lblDistrict; private javax.swing.JLabel lblState; // End of variables declaration//GEN-END:variables private void countryChange() { String chosenCountry = cboCountry.getSelectedItem().toString(); currentLocation = getLocationDetails(countryList, chosenCountry); if (currentLocation.getLocid() == 0) { chosenLocation.setText(""); chosenLocationId.setText(""); } else { chosenLocation.setText(currentLocation.getLname().toUpperCase()); chosenLocationId.setText(currentLocation.getLocid().toString()); loadState(currentLocation.getLocid()); } } private void loadState(Integer locid) { if (namingConvention.equals(NamingConvention.OTHER_CROPS)) { loadStatesOtherCrops(locid); } else { loadStatesForCimmyt(locid); } } private void loadStatesOtherCrops(Integer locid) { Location locationFilter = new Location(true); locationFilter.setLtype(406); locationFilter.setLrplce(0); locationFilter.setCntryid(locid); SortedComboBoxModel cboStateModel = new SortedComboBoxModel(); SortedComboBoxModel cboDistrictModel = new SortedComboBoxModel(); provinceList = AppServicesProxy.getDefault().appServices().getListLocation(locationFilter, 0, 0, false); if (provinceList.isEmpty()) { cboStateModel.addElement("-No States/Provinces for " + currentLocation.getLname() + "-"); } else { for (Location province : provinceList) { cboStateModel.addElement(province.getLname()); } cboStateModel.addElement("-Choose State/Province-"); } cboState.setModel(cboStateModel); cboState.setSelectedIndex(0); cboDistrictModel.removeAllElements(); cboDistrict.setModel(cboDistrictModel); } private void loadStatesForCimmyt(Integer locid) { SortedComboBoxModel cboStateModel = new SortedComboBoxModel(); SortedComboBoxModel cboDistrictModel = new SortedComboBoxModel(); provinceList = AppServicesProxy.getDefault().appServices().getLocationsByCountryLocidRange(locid, 8000, 10000); if (provinceList.isEmpty()) { cboStateModel.addElement("-No States/Provinces for " + currentLocation.getLname() + "-"); } else { for (Location province : provinceList) { cboStateModel.addElement(province.getLname()); } cboStateModel.addElement("-Choose State/Province-"); } cboState.setModel(cboStateModel); cboState.setSelectedIndex(0); cboDistrictModel.removeAllElements(); cboDistrict.setModel(cboDistrictModel); } private void stateChange() { String chosenState = cboState.getSelectedItem().toString(); currentLocation = getLocationDetails(provinceList, chosenState); if (currentLocation != null) { if (currentLocation.getLocid() != 0) { chosenLocation.setText(currentLocation.getLname()); chosenLocationId.setText(currentLocation.getLocid().toString()); if (namingConvention.equals(NamingConvention.OTHER_CROPS)) { loadDistrict(currentLocation.getCntryid(), currentLocation.getLocid()); } } } } private void loadDistrict(Integer cntryid, Integer locid) { Location locationFilter = new Location(true); locationFilter.setLrplce(0); locationFilter.setCntryid(cntryid); locationFilter.setSnl1id(locid); SortedComboBoxModel cboDistrictModel = new SortedComboBoxModel(); districtList = AppServicesProxy.getDefault().appServices().getListLocation(locationFilter, 0, 0, false); if (districtList.isEmpty()) { cboDistrictModel.addElement("-No entries for " + currentLocation.getLname() + "-"); } else { for (Location loc : districtList) { if (loc.getLocid().intValue() != loc.getSnl1id().intValue()) { cboDistrictModel.addElement(loc.getLname()); } } if (cboDistrictModel.getSize() > 0) { cboDistrictModel.addElement("-Choose District/City/Town-"); } else { cboDistrictModel.addElement("-No entries for " + currentLocation.getLname() + "-"); } } cboDistrict.setModel(cboDistrictModel); cboDistrict.setSelectedIndex(0); } private void districtChange() { String chosenDistrict = cboDistrict.getSelectedItem().toString(); currentLocation = getLocationDetails(districtList, chosenDistrict); if (currentLocation != null) { if (currentLocation.getLocid() != 0) { chosenLocation.setText(currentLocation.getLname()); chosenLocationId.setText(currentLocation.getLocid().toString()); } } } private void initAllLocations() { Location locationFilter = new Location(true); locationFilter.setLrplce(0); if (onlyShowInventoryLocations) { locationFilter.setLtype(Location.LTYPE_STORAGE_SEED_STOCK_LOCATION); } allLocation = AppServicesProxy.getDefault().appServices().getListLocation(locationFilter, 0, 0, false); SortedComboBoxModel cboLocationModel = new SortedComboBoxModel(); for (Location location : allLocation) { if (!location.getLname().startsWith("-")) { cboLocationModel.addElement(location.getLname()); } } } private void getLocationById() { if (!chosenLocationId.getText().isEmpty()) { int chosenLocId = Integer.parseInt(chosenLocationId.getText()); currentLocation = getLocationDetails(allLocation, chosenLocId); System.out.println("\n current location of inputted loc id is " + currentLocation.getLname()); if (currentLocation != null) { if (currentLocation.getLocid() != 0) { chosenLocation.setText(currentLocation.getLname()); chosenLocationId.setText(currentLocation.getLocid().toString()); } } } } private Location getLocationDetails(List<Location> list, String loctn) { Location location = null; for (Location loc : list) { if (loc.getLname().equals(loctn)) { location = loc; } } return location; } private Location getLocationDetails(List<Location> list, int locid) { Location location = null; for (Location loc : list) { if (loc.getLocid().intValue() == locid) { location = loc; } } return location; } private void clearFields(int scope) { switch (scope) { case 0: cboCountry.setModel(new SortedComboBoxModel()); case 1: cboState.setModel(new SortedComboBoxModel()); case 2: cboDistrict.setModel(new SortedComboBoxModel()); case 4: chosenLocation.setText(""); chosenLocationId.setText(""); break; default: System.out.println("Unknown scope code. nothing is cleared."); break; } } public Integer getLocationId() { Integer locationId = null; if (!chosenLocationId.getText().trim().isEmpty()) { locationId = Integer.parseInt(chosenLocationId.getText()); } return locationId; } public String getLocationName() { String locationName = ""; if (!chosenLocation.getText().trim().isEmpty()) { locationName = chosenLocation.getText(); } return locationName; } public Location getSelectedLocation() { getLocationById(); return currentLocation; } public boolean isOlyShowInventoryLocations() { return onlyShowInventoryLocations; } public void setOnlyShowInventoryLocations(boolean selectInventoryLocations) { this.onlyShowInventoryLocations = selectInventoryLocations; assignInventoryLocations(); } }
[ "alvince@4ebb2e00-0138-4608-bc6e-edf3948d4863" ]
alvince@4ebb2e00-0138-4608-bc6e-edf3948d4863
008ee1d1de58da4e41d6b7e923d0591e67fbe340
1d31c703e8152402b0c34830739d4356c2fbd490
/KTMRepo/JavaPrj/src/BackJoon/B3046.java
d2d8103ea03ae4d102eb98128846561eedf5e166
[]
no_license
greatjade24/KTMRepo
949a84cebc52cb0d5eab123e882d9910e55003cb
9207150f6238329bfbf4ca314b289435d8f57659
refs/heads/master
2023-09-06T08:29:51.087666
2021-11-22T02:06:12
2021-11-22T02:06:12
262,197,933
3
0
null
null
null
null
UTF-8
Java
false
false
267
java
package BackJoon; import java.util.Scanner; public class B3046 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int r1 = sc.nextInt(); int avg = sc.nextInt(); int r2 = avg * 2 - r1; System.out.println(r2); } }
a79033aeecebc0953209ff84517d6a0728a0bf16
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/23/23_4d6d1958fb4d2d70450dafd761cd0b5ee3ec0e09/BrokerListener/23_4d6d1958fb4d2d70450dafd761cd0b5ee3ec0e09_BrokerListener_s.java
30fdf5c7340d9f8d24c985ab7958916a5b3486b1
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
53,216
java
package me.ellbristow.broker; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.block.Sign; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class BrokerListener implements Listener { private static Broker plugin; public BrokerListener (Broker instance) { plugin = instance; } @EventHandler (priority = EventPriority.NORMAL) public void onInventoryClick(InventoryClickEvent event) { if (event.isCancelled()) return; Inventory inv = event.getView().getTopInventory(); if (inv.getName().startsWith("<Broker>")) { String seller = ""; boolean buyOrders = false; if (inv.getName().equals("<Broker> Buy Orders")) { buyOrders = true; } else if (inv.getName().equals("<Broker> Buy Cancel")) { buyOrders = true; seller = "Cancel"; } else if (inv.getName().equals("<Broker> Sell Cancel")) { seller = "Cancel"; } else if (inv.getName().equals("<Broker> Buy AdminCancel")) { buyOrders = true; seller = "ADMIN"; } else if (inv.getName().equals("<Broker> Sell AdminCancel")) { seller = "ADMIN"; } else { seller = inv.getName().split(" ")[1]; } if (!seller.equals("Cancel") && !seller.equals("ADMIN")) { if (seller.equals("Buy")) seller = ""; Player player = (Player)event.getWhoClicked(); Player buyer; buyer = player; int slot = event.getRawSlot(); if (slot >= 45 && slot <54) { event.setCancelled(true); // Clicked navigation slot Material itemType = inv.getItem(slot).getType(); if (itemType == Material.BOOK) { // Main Page inv.setContents(plugin.getBrokerInv("0", buyer, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + "Main Page"); } else if (itemType == Material.PAPER) { // Change Page if (inv.getItem(0).getType() != Material.BOOK) { // On Main Page inv.setContents(plugin.getBrokerInv((slot-45)+"", buyer, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + "Page " + (slot-44)); } else { // On Sub Page String itemName = inv.getItem(0).getType().name(); inv.setContents(plugin.getBrokerInv(itemName+"::"+(slot-45), buyer, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + itemName); player.sendMessage(ChatColor.GOLD + "Page " + (slot-44)); } } } else if (slot >= 0 && slot < 45 && inv.getItem(slot) != null && inv.getItem(45).getType() != Material.BOOK) { // Clicked item on Main Page event.setCancelled(true); Material itemType = inv.getItem(slot).getType(); String itemName = itemType.name(); if (!plugin.isDamageableItem(new ItemStack(Material.getMaterial(itemName)))) { itemName += ":"+inv.getItem(slot).getDurability(); } inv.setContents(plugin.getBrokerInv(itemName+"::0", buyer, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + itemType.name()); player.sendMessage(ChatColor.GOLD + "Page 1"); } else if (slot >= 0 && slot < 45 && inv.getItem(slot) != null) { // Clicked item on sub-page event.setCancelled(true); String priceString = getPrice(inv,slot, null); String[] priceSplit = priceString.split(":"); double price = Double.parseDouble(priceSplit[0]); int perItems = Integer.parseInt(priceSplit[1]); String each = "each"; if (perItems != 1) { each = "for " + perItems; } if (buyOrders) { player.sendMessage(ChatColor.GOLD + "Buy Order Details:"); player.sendMessage(ChatColor.GOLD + " Max Price Each: " + ChatColor.WHITE + plugin.vault.economy.format(price)); player.sendMessage(ChatColor.GOLD + " Max Quant: " + ChatColor.WHITE + perItems); player.sendMessage(ChatColor.GOLD + "To sell an item, Try:"); player.sendMessage(" /broker sell [price] {Per # Items}!"); final String playerName = player.getName(); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { Player runPlayer = plugin.getServer().getPlayer(playerName); runPlayer.closeInventory(); runPlayer.updateInventory(); } }, 5L); } else if (price != 0.00) { player.sendMessage(ChatColor.GOLD + "Price: " + ChatColor.WHITE + plugin.vault.economy.format(price) + " ("+each+")"); HashMap<Integer,String> slotPrice = new HashMap<Integer,String>(); slotPrice.put(slot,price+":"+perItems); final HashMap<ItemStack,String> pending = new HashMap<ItemStack,String>(); pending.put(inv.getItem(slot),price+":"+perItems); plugin.pending.put(player.getName(), pending); player.sendMessage("Enter quantity to buy at this price"); player.sendMessage("(Enter 0 to cancel)"); final String playerName = player.getName(); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { Player runPlayer = plugin.getServer().getPlayer(playerName); runPlayer.closeInventory(); runPlayer.updateInventory(); } }, 5L); plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override public void run () { if (plugin.pending.containsKey(playerName)) { HashMap<ItemStack, String> thisPending = plugin.pending.get(playerName); if (thisPending.equals(pending)) { Player runPlayer = plugin.getServer().getPlayer(playerName); if (runPlayer != null) { runPlayer.sendMessage(ChatColor.RED + "You took too long to specify a quantity. Order Cancelled!"); } plugin.pending.remove(playerName); } } } }, 200L); } else { final String playerName = player.getName(); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { Player runPlayer = plugin.getServer().getPlayer(playerName); runPlayer.closeInventory(); runPlayer.updateInventory(); } }, 5L); player.sendMessage(ChatColor.RED + "Sorry! This item may not be available any more!"); player.sendMessage(ChatColor.RED + "Please try again."); } } else if (event.isShiftClick() && event.isLeftClick()) { event.setCancelled(true); } else if (slot >= 0 && slot < 54 && event.getCursor() != null) { event.setCancelled(true); } } else { // Cancelling Orders Player player = (Player)event.getWhoClicked(); if (!seller.equals("ADMIN")) { seller = player.getName(); } int slot = event.getRawSlot(); if (slot >= 45 && slot <54) { event.setCancelled(true); // Clicked navigation slot Material itemType = inv.getItem(slot).getType(); if (itemType == Material.BOOK) { // Main Page inv.setContents(plugin.getBrokerInv("0", player, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + "Main Page"); } else if (itemType == Material.PAPER) { // Change Page if (inv.getItem(0).getType() != Material.BOOK) { // On Main Page inv.setContents(plugin.getBrokerInv((slot-45)+"", player, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + "Page " + (slot-44)); } else { // On Sub Page String itemName = inv.getItem(0).getType().name(); inv.setContents(plugin.getBrokerInv(itemName+"::"+(slot-45), player, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + itemName); player.sendMessage(ChatColor.GOLD + "Page " + (slot-44)); } } } else if (slot >= 0 && slot < 45 && inv.getItem(slot) != null && inv.getItem(45).getType() != Material.BOOK) { // Clicked item on Main Page event.setCancelled(true); Material itemType = inv.getItem(slot).getType(); String itemName = itemType.name(); if (!plugin.isDamageableItem(new ItemStack(Material.getMaterial(itemName)))) { itemName += ":"+inv.getItem(slot).getDurability(); } inv.setContents(plugin.getBrokerInv(itemName+"::0", player, seller, buyOrders).getContents()); player.sendMessage(ChatColor.GOLD + itemType.name()); player.sendMessage(ChatColor.GOLD + "Page 1"); } else if (slot >= 0 && slot < 45 && inv.getItem(slot) != null) { // Clicked item on sub-page // Cancel Order int orderType = 0; String perItemsString = " AND perItems = "; if (buyOrders) { orderType = 1; perItemsString = ""; } event.setCancelled(true); ItemStack stack = inv.getItem(slot); Map<Enchantment, Integer> enchantments = stack.getEnchantments(); String enchantmentString = ""; if (!enchantments.isEmpty()) { enchantmentString = " AND enchantments = '"; Object[] enchs = enchantments.keySet().toArray(); for (Object ench : enchs) { if (!" AND enchantments = '".equals(enchantmentString)) { enchantmentString += ";"; } enchantmentString += ((Enchantment)ench).getId() + "@" + enchantments.get((Enchantment)ench); } enchantmentString += "'"; } String priceString; if (seller.equals("ADMIN")) { priceString = getPrice(inv, slot, "ADMIN"); } else { priceString = getPrice(inv, slot, player.getName()); } String[] priceSplit = priceString.split(":"); double price = Double.parseDouble(priceSplit[0]); int perItems = Integer.parseInt(priceSplit[1]); if (!buyOrders) { perItemsString += perItems; } HashMap<Integer, HashMap<String, Object>> orders; if (seller.equals("ADMIN")) { orders = plugin.brokerDb.select("id, quant, playerName","BrokerOrders","orderType = "+orderType+" AND itemName = '" + stack.getType().name() + "' AND damage = " + stack.getDurability() + enchantmentString + " AND price = " + price + perItemsString,null,null); } else { orders = plugin.brokerDb.select("id, quant, playerName","BrokerOrders","playerName = '" + player.getName() + "' AND orderType = "+orderType+" AND itemName = '" + stack.getType().name() + "' AND damage = " + stack.getDurability() + enchantmentString + " AND price = " + price + perItemsString,null,null); } int totQuant = 0; HashMap<String, Double> refunds = new HashMap<String,Double>(); for (int i = 0; i < orders.size(); i++) { int orderId = (Integer)orders.get(i).get("id"); int quant = (Integer)orders.get(i).get("quant"); totQuant += quant; String buyerName = (String)orders.get(i).get("playerName"); double thisRefund = quant * price; if (plugin.taxOnBuyOrders) { double fee = plugin.calcTax(thisRefund); thisRefund += fee; plugin.distributeTax(fee); } if (refunds.containsKey(buyerName)) { double oldRefund = refunds.get(buyerName); refunds.put(buyerName, oldRefund + thisRefund); } else { refunds.put(buyerName, thisRefund); } String query = "DELETE FROM BrokerOrders WHERE id = " + orderId; plugin.brokerDb.query(query); } stack.setAmount(totQuant); String itemName = stack.getType().name(); if (!plugin.isDamageableItem(new ItemStack(Material.getMaterial(itemName)))) { itemName += ":"+inv.getItem(slot).getDurability(); } inv.setContents(plugin.getBrokerInv(itemName+"::0", player, seller, buyOrders).getContents()); if (inv.getItem(0) == null) { inv.setContents(plugin.getBrokerInv("0", player, seller, buyOrders).getContents()); } if (buyOrders) { if (seller.equals("ADMIN")) { player.sendMessage(ChatColor.GOLD + "Buy Order(s) Cancelled"); } for (String buyerName : refunds.keySet()) { OfflinePlayer buyer = Bukkit.getOfflinePlayer(buyerName); double refund = refunds.get(buyerName); plugin.vault.economy.depositPlayer(buyerName, refund); if (buyer.isOnline()) { buyer.getPlayer().sendMessage(ChatColor.GOLD + "Buy Order Cancelled"); buyer.getPlayer().sendMessage(ChatColor.GRAY + "You were refunded " + ChatColor.WHITE + plugin.vault.economy.format(refund)); } } } else { player.sendMessage(ChatColor.GOLD + "Sell Order Cancelled"); } if (!buyOrders) { HashMap<Integer, ItemStack> dropped = player.getInventory().addItem(stack); if (!dropped.isEmpty()) { player.sendMessage(ChatColor.RED + "Not all items could fit in your Inventory!"); player.sendMessage(ChatColor.RED + "Look on the floor!"); for (int i = 0; i < dropped.size(); i++) { player.getWorld().dropItem(player.getLocation(), dropped.get(i)); } } } } else if (event.isShiftClick() && event.isLeftClick()) { event.setCancelled(true); } else if (slot >= 0 && slot < 54 && event.getCursor() != null) { event.setCancelled(true); } } } } @EventHandler (priority = EventPriority.NORMAL) public void onPlayerChat(AsyncPlayerChatEvent event) { if (!event.isCancelled()) { Player player = event.getPlayer(); if (plugin.pending.containsKey(player.getName())) { event.setCancelled(true); int quantity = 0; try { quantity = Integer.parseInt(event.getMessage()); } catch (NumberFormatException nfe) { plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.RED + "Invalid quantity. Order Cancelled!"); } if (quantity <= 0) { plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.RED + "Order Cancelled!"); } else { HashMap<ItemStack, String> pending = plugin.pending.get(player.getName()); Object[] items = pending.keySet().toArray(); ItemStack stack = (ItemStack)items[0]; Map<Enchantment, Integer> enchantments = stack.getEnchantments(); String enchantmentString = ""; String enchanted = ""; if (!enchantments.isEmpty()) { enchantmentString = " AND enchantments = '"; enchanted = " (Enchanted)"; Object[] enchs = enchantments.keySet().toArray(); for (Object ench : enchs) { if (!" AND enchantments = '".equals(enchantmentString)) { enchantmentString += ";"; } enchantmentString += ((Enchantment)ench).getId() + "@" + enchantments.get((Enchantment)ench); } enchantmentString += "'"; } if (plugin.isDamageableItem(stack) && stack.getDurability() != 0) { enchanted += "(Damaged)"; } String priceString = pending.get(stack); String[] priceSplit = priceString.split(":"); double price = Double.parseDouble(priceSplit[0]); int perItems = Integer.parseInt(priceSplit[1]); quantity = (int)(quantity / perItems) * perItems; if (quantity == 0) { plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.RED + "You must buy at least "+perItems+" items for this order!"); player.sendMessage(ChatColor.RED + "Order Cancelled!"); return; } HashMap<Integer, HashMap<String, Object>> sellOrders = plugin.brokerDb.select("SUM(quant) as totQuant","BrokerOrders", "orderType = 0 AND itemName = '" + stack.getType().name() + "' AND price = " + price + " AND perItems = "+perItems+" AND damage = " + stack.getDurability() + enchantmentString, null, "timeCode ASC"); if (sellOrders != null) { try { int tot = 0; for (int i = 0; i < sellOrders.size(); i++) { if (tot == 0) { tot = (Integer)sellOrders.get(i).get("totQuant"); } } if (quantity > tot) { player.sendMessage(ChatColor.RED + "Only " + ChatColor.WHITE + tot + ChatColor.RED + " were available at this price!"); quantity = tot; } double totPrice = quantity * price / perItems; if (plugin.vault.economy.getBalance(player.getName()) < totPrice) { player.sendMessage(ChatColor.RED + "You cannot afford " + quantity + " of those!"); player.sendMessage(ChatColor.RED + "Total Price: " + plugin.vault.economy.format(totPrice)); player.sendMessage(ChatColor.RED + "Order Cancelled!"); plugin.pending.remove(player.getName()); } else { stack.setAmount(quantity); plugin.vault.economy.withdrawPlayer(player.getName(), totPrice); HashMap<Integer, ItemStack> drop = player.getInventory().addItem(stack); if (!drop.isEmpty()) { player.sendMessage(ChatColor.YELLOW + "Some items did not fit in your inventory! Look on the floor!"); for (int i = 0; i < drop.size(); i++) { ItemStack dropStack = drop.get(i); player.getWorld().dropItem(player.getLocation(), dropStack); } } player.sendMessage(ChatColor.GOLD + "You bought " + ChatColor.WHITE + quantity + " " + stack.getType().name() + enchanted + ChatColor.GOLD + " for " + ChatColor.WHITE + plugin.vault.economy.format(totPrice)); HashMap<Integer, HashMap<String, Object>> playerOrders = plugin.brokerDb.select("playerName, SUM(quant) AS quant, timeCode", "BrokerOrders", "orderType = 0 AND itemName = '" + stack.getType().name() + "' AND price = " + price + " AND damage = " + stack.getDurability() + enchantmentString,"playerName", "timeCode ASC"); int allocated = 0; HashMap<String,Integer> allSellers = new HashMap<String, Integer>(); for (int i =0; i < playerOrders.size(); i++) { String playerName = (String)playerOrders.get(i).get("playerName"); int playerQuant = (Integer)playerOrders.get(i).get("quant"); allSellers.put(playerName,playerQuant); } Object[] sellers = allSellers.keySet().toArray(); for (int i = 0; i < sellers.length; i++) { String sellerName = (String)sellers[i]; int quant = allSellers.get(sellerName); OfflinePlayer seller = plugin.getServer().getOfflinePlayer(sellerName); if (quantity - allocated >= quant) { allocated += quant; double tax = plugin.calcTax(quant * price); plugin.vault.economy.depositPlayer(sellerName, (quant * price) - tax); plugin.distributeTax(tax); String thisquery = "DELETE FROM BrokerOrders WHERE playername = '" + sellerName + "' AND orderType = 0 AND itemName = '" + stack.getType().name() + "' AND price = " + price + " AND damage = " + stack.getDurability() + enchantmentString; plugin.brokerDb.query(thisquery); if (seller.isOnline()) { seller.getPlayer().sendMessage(ChatColor.GOLD + "[Broker] " + ChatColor.WHITE + player.getName() + ChatColor.GOLD + " bought " + ChatColor.WHITE + quant + " " + stack.getType().name() + enchanted + ChatColor.GOLD + " for " + ChatColor.WHITE + plugin.vault.economy.format(quant * price)); if (tax > 0) { seller.getPlayer().sendMessage(ChatColor.GOLD + "[Broker] You were charged sales tax of " + ChatColor.WHITE + plugin.vault.economy.format(tax)); } } } else { int deduct = quantity - allocated; int selling = deduct; double tax = plugin.calcTax(deduct * price); plugin.vault.economy.depositPlayer(sellerName, (deduct * price) - tax); plugin.distributeTax(tax); HashMap<Integer, HashMap<String, Object>> sellerOrders = plugin.brokerDb.select("id, quant","BrokerOrders", "playername = '" + sellerName + "' AND orderType = 0 AND itemName = '" + stack.getType().name() + "' AND price = " + price + " AND damage = " + stack.getDurability() + enchantmentString, null, "timeCode ASC"); Set<String> queries = new HashSet<String>(); for (int j = 0; j < sellerOrders.size(); j++) { if (deduct != 0) { int sellQuant = (Integer)sellerOrders.get(j).get("quant"); if (sellQuant <= deduct) { queries.add("DELETE FROM BrokerOrders WHERE id = " + (Integer)sellerOrders.get(j).get("id")); deduct -= sellQuant; } else { queries.add("UPDATE BrokerOrders SET quant = quant - " + deduct + " WHERE id = " + (Integer)sellerOrders.get(j).get("id")); deduct = 0; } } } Object[]queryStrings = queries.toArray(); for (Object thisquery : queryStrings) { plugin.brokerDb.query((String)thisquery); } if (seller.isOnline()) { seller.getPlayer().sendMessage(ChatColor.GOLD + "[Broker] " + ChatColor.WHITE + player.getName() + ChatColor.GOLD + " bought " + ChatColor.WHITE + selling + " " + stack.getType().name() + enchanted + ChatColor.GOLD + " for " + ChatColor.WHITE + plugin.vault.economy.format(selling * price)); if (tax > 0) { seller.getPlayer().sendMessage(ChatColor.GOLD + "[Broker] You were charged sales tax of " + ChatColor.WHITE + plugin.vault.economy.format(tax)); } } allocated = quantity; } } } } catch(Exception e) { } } else { player.sendMessage(ChatColor.RED + "Sorry! This item may not be available any more!"); player.sendMessage(ChatColor.RED + "Please try again."); } plugin.pending.remove(player.getName()); } plugin.pending.remove(player.getName()); } } } @EventHandler (priority = EventPriority.NORMAL) public void onSignChange(SignChangeEvent event) { if (event.isCancelled()) return; String line0 = event.getLine(0); String line3 = event.getLine(3); if (line0.equalsIgnoreCase("[Broker]")) { Player player = event.getPlayer(); if (!player.hasPermission("broker.sign") && !player.hasPermission("broker.sign.personal") && !player.hasPermission("broker.sign.personal.others") && !player.hasPermission("broker.sign.buyorders") && !player.hasPermission("broker.sign.autosell") && !player.hasPermission("broker.sign.pricecheck")) { player.sendMessage(ChatColor.RED + "You do not have permission to create broker signs!"); event.getBlock().breakNaturally(); return; } else if (player.hasPermission("broker.sign.personal") && !player.hasPermission("broker.sign") && !player.hasPermission("broker.sign.personal.others") && !player.hasPermission("broker.sign.buyorders") && !player.hasPermission("broker.sign.autosell") && !player.hasPermission("broker.sign.pricecheck")) { event.setLine(3, player.getName()); } else if ((player.hasPermission("broker.sign.personal") || player.hasPermission("broker.sign.personal.others") || player.hasPermission("broker.sign.buyorders") || player.hasPermission("broker.sign.autosell") || player.hasPermission("broker.sign.pricecheck") || player.hasPermission("broker.sign")) && !line3.equals("")) { if (line3.equalsIgnoreCase("Buy Orders") || line3.equalsIgnoreCase("BuyOrders")) { if (player.hasPermission("broker.sign.buyorders")) { event.setLine(3, "Buy Orders"); } else { player.sendMessage(ChatColor.RED + "You do not have permission to create Broker Buy Order signs!"); event.getBlock().breakNaturally(); return; } } else if (line3.equalsIgnoreCase("Auto Sell") || line3.equalsIgnoreCase("AutoSell")) { if (player.hasPermission("broker.sign.autosell")) { event.setLine(3, "Auto Sell"); } else { player.sendMessage(ChatColor.RED + "You do not have permission to create Broker Auto Sell signs!"); event.getBlock().breakNaturally(); return; } } else if (line3.equalsIgnoreCase("Price Check") || line3.equalsIgnoreCase("PriceCheck")) { if (player.hasPermission("broker.sign.pricecheck")) { event.setLine(3, "Price Check"); } else { player.sendMessage(ChatColor.RED + "You do not have permission to create Broker Price Check signs!"); event.getBlock().breakNaturally(); return; } } else if (!player.hasPermission("broker.sign.personal.others")) { event.setLine(3, player.getName()); } else { OfflinePlayer target = plugin.getServer().getOfflinePlayer(line3); if (!target.hasPlayedBefore()) { player.sendMessage(ChatColor.RED + "Player " + ChatColor.WHITE + line3 + ChatColor.RED + " not found!"); event.getBlock().breakNaturally(); return; } event.setLine(3, target.getName()); } } event.setLine(0, "[Broker]"); } } @EventHandler (priority = EventPriority.NORMAL) public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) return; if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && (event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) && ((Sign)event.getClickedBlock().getState()).getLine(0).equalsIgnoreCase("[Broker]")) { Player player = event.getPlayer(); if (!player.hasPermission("broker.use")) { player.sendMessage(ChatColor.RED + "You do not have permission to use the broker!"); event.setCancelled(true); return; } Sign sign = (Sign)event.getClickedBlock().getState(); String sellerName = sign.getLine(3); String openString = "<Broker> Main Page"; if (sellerName.equals("")) { player.openInventory(plugin.getBrokerInv("0", player, null, false)); } else { if (!sellerName.equals("Buy Orders") && !sellerName.equals("Auto Sell") && !sellerName.equals("Price Check")) { OfflinePlayer seller = plugin.getServer().getOfflinePlayer(sellerName); if (!seller.hasPlayedBefore()) { player.sendMessage(ChatColor.RED + "Sorry! This shop appears to be closed!"); event.setCancelled(true); return; } player.openInventory(plugin.getBrokerInv("0", player, seller.getName(), false)); } else if (sellerName.equals("Buy Orders")) { player.openInventory(plugin.getBrokerInv("0", player, "", true)); openString = "<Broker> Buy Orders"; } else if (sellerName.equals("Auto Sell")) { // Attempt Auto Sell ItemStack stack = player.getItemInHand(); if (stack == null || stack.getType().equals(Material.AIR)) { player.sendMessage(ChatColor.RED + "You are not holding anything to Auto Sell!"); event.setCancelled(true); return; } if (!stack.getEnchantments().isEmpty() || stack.hasItemMeta()) { player.sendMessage(ChatColor.RED + "You cannot Auto Sell items with enchantments or with ItemMeta data!"); event.setCancelled(true); return; } HashMap<Integer, HashMap<String, Object>> buyOrders = plugin.brokerDb.select("id, playerName, price, quant", "BrokerOrders", "orderType = 1 AND itemName = '"+stack.getType()+"' AND damage = " + stack.getDurability() + " AND enchantments = '' AND meta = ''", null, "price DESC, timeCode ASC"); if (buyOrders.isEmpty()) { player.sendMessage(ChatColor.RED + "No valid Buy Orders were found for that item!"); event.setCancelled(true); return; } // Orders Found int sold = 0; int cost = 0; for (Integer buyOrderId : buyOrders.keySet()) { HashMap<String, Object> buyOrder = buyOrders.get(buyOrderId); int id = Integer.parseInt(buyOrder.get("id").toString()); String buyerName = (String)buyOrder.get("playerName"); double price = Double.parseDouble(buyOrder.get("price").toString()); int quant = Integer.parseInt(buyOrder.get("quant").toString()); int thisSale = 0; ItemStack boughtStack = stack.clone(); if (quant <= stack.getAmount()) { thisSale += quant; plugin.brokerDb.query("DELETE FROM BrokerOrders WHERE id = " + id); } else { thisSale += stack.getAmount(); plugin.brokerDb.query("UPDATE BrokerOrders SET quant = "+(quant-thisSale)+" WHERE id = " + id); } if (thisSale != 0) { sold += thisSale; boughtStack.setAmount(thisSale); double thisCost = boughtStack.getAmount() * price/perItems; cost += thisCost; OfflinePlayer buyer = Bukkit.getOfflinePlayer(buyerName); if (buyer.isOnline()) { Player onlineBuyer = buyer.getPlayer(); onlineBuyer.sendMessage(ChatColor.GOLD + "You bought " + ChatColor.WHITE + boughtStack.getAmount() + " " + boughtStack.getType() + ChatColor.GOLD + " for " + ChatColor.WHITE + plugin.vault.economy.format(thisCost/perItems)); HashMap<Integer, ItemStack> dropped = onlineBuyer.getInventory().addItem(boughtStack); if (!dropped.isEmpty()) { for (ItemStack dropStack : dropped.values()) { onlineBuyer.getWorld().dropItem(onlineBuyer.getLocation(), dropStack); } onlineBuyer.sendMessage(ChatColor.RED + "Not all bought items fit in your inventory! Check the floor!"); } } else { // List as pending plugin.brokerDb.query("INSERT INTO BrokerPending (playerName, itemName, damage, quant) VALUES ('"+buyerName+"', '"+boughtStack.getType()+"', "+boughtStack.getDurability()+", "+boughtStack.getAmount()+")"); } } } if (sold == stack.getAmount()) { player.setItemInHand(null); } else { stack.setAmount(stack.getAmount() - sold); } double fee = plugin.calcTax(cost); plugin.vault.economy.depositPlayer(player.getName(), cost - fee); plugin.distributeTax(fee); player.sendMessage(ChatColor.GOLD + "You sold " + ChatColor.WHITE + sold + " " + stack.getType() + ChatColor.GOLD + " for " + ChatColor.WHITE + plugin.vault.economy.format(cost)); if (fee != 0) { player.sendMessage(ChatColor.GOLD + "Broker Fee : " + ChatColor.WHITE + plugin.vault.economy.format(fee)); } event.setCancelled(true); return; } else if (sellerName.equals("Price Check")) { if (!player.hasPermission("broker.sign.pricecheck.update")) { player.sendMessage(ChatColor.RED + "You don not have permission to update Price Check signs!"); event.setCancelled(true); return; } ItemStack stack = player.getItemInHand(); if (stack == null || stack.getType().equals(Material.AIR)) { player.sendMessage(ChatColor.RED + "You are not holding anything to Price Check!"); event.setCancelled(true); return; } if (!stack.getEnchantments().isEmpty() || stack.hasItemMeta()) { player.sendMessage(ChatColor.RED + "You cannot Price Check items with enchantments or with ItemMeta data!"); event.setCancelled(true); return; } HashMap<Integer, HashMap<String, Object>> buyOrders = plugin.brokerDb.select("price, quant", "BrokerOrders", "orderType = 1 AND itemName = '"+stack.getType()+"' AND damage = " + stack.getDurability() + " AND enchantments = '' AND meta = ''", null, "price DESC, timeCode ASC"); if (buyOrders.isEmpty()) { player.sendMessage(ChatColor.RED + "No valid Buy Orders were found for that item!"); event.setCancelled(true); return; } HashMap<String, Object> order = buyOrders.get(0); sign.setLine(1, stack.getType().name()); sign.setLine(2, order.get("price").toString() + " (" + order.get("quant") + ")"); sign.update(); event.setCancelled(true); return; } } plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.GOLD + openString); player.sendMessage(ChatColor.GOLD + "Choose an Item Type"); event.setCancelled(true); } } @EventHandler (priority = EventPriority.NORMAL) public void onPlayerTrade(PlayerInteractEntityEvent event) { if (event.isCancelled()) return; if (!event.getPlayer().isSneaking()) return; if (!event.getPlayer().hasPermission("broker.use")) return; Entity entity = event.getRightClicked(); if (!(entity instanceof Player) && !(entity instanceof Villager)) return; Player player = event.getPlayer(); if (entity instanceof Player && plugin.brokerPlayers) { Player target = (Player)entity; Inventory inv = plugin.getBrokerInv("0", player, target.getName(), false); if (inv == null || inv.getItem(0) == null) { player.sendMessage(ChatColor.RED + "This player is not selling anything!"); return; } player.openInventory(inv); plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.GOLD + "<BROKER> Main Page"); player.sendMessage(ChatColor.GOLD + "Choose an Item Type"); event.setCancelled(true); } else if (entity instanceof Villager && plugin.brokerVillagers) { player.openInventory(plugin.getBrokerInv("0", player, null, false)); plugin.pending.remove(player.getName()); player.sendMessage(ChatColor.GOLD + "<BROKER> Main Page"); player.sendMessage(ChatColor.GOLD + "Choose an Item Type"); event.setCancelled(true); } } @EventHandler (priority = EventPriority.NORMAL) public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled()) return; if ((event.getBlock().getType().equals(Material.SIGN_POST) || event.getBlock().getType().equals(Material.WALL_SIGN)) && ((Sign)event.getBlock().getState()).getLine(0).equalsIgnoreCase("[Broker]")) { String owner = ((Sign)event.getBlock().getState()).getLine(3); Player player = event.getPlayer(); Sign sign = (Sign)event.getBlock().getState(); if (!player.hasPermission("broker.sign") && !player.hasPermission("broker.sign.personal") && !player.hasPermission("broker.sign.personal.others") && !player.hasPermission("broker.sign.buyorders") && !player.hasPermission("broker.sign.autosell")) { event.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break Broker signs!"); event.setCancelled(true); sign.setLine(0, sign.getLine(0)); sign.update(); } else if (sign.getLine(3).equals("Buy Orders") && !player.hasPermission("broker.sign.buyorders")) { event.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break Broker Buy Order signs!"); event.setCancelled(true); sign.setLine(0, sign.getLine(0)); sign.update(); } else if (sign.getLine(3).equals("Auto Sell") && !player.hasPermission("broker.sign.autosell")) { event.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break Broker Auto Sell signs!"); event.setCancelled(true); sign.setLine(0, sign.getLine(0)); sign.update(); } else if (sign.getLine(3).equals("Price Check") && !player.hasPermission("broker.sign.pricecheck")) { event.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to break Broker Price Check signs!"); event.setCancelled(true); sign.setLine(0, sign.getLine(0)); sign.update(); } else if (player.hasPermission("broker.sign.personal") && !player.hasPermission("broker.sign.personal.others") && !owner.equalsIgnoreCase(player.getName())) { event.getPlayer().sendMessage(ChatColor.RED + "This is not your sign to break!"); event.setCancelled(true); sign.setLine(0, sign.getLine(0)); sign.update(); } } } @EventHandler (priority = EventPriority.NORMAL) public void onVillagerDamage(EntityDamageByEntityEvent event) { if (event.isCancelled()) return; if (!plugin.brokerVillagers) return; Entity damager = event.getDamager(); Entity target = event.getEntity(); if (damager instanceof Player && target instanceof Villager) { Player player = (Player)damager; if (!player.hasPermission("broker.admin")) { event.setCancelled(true); } } } private String getPrice(Inventory inv, int slot, String sellerName) { double price = 0.00; int perItems = 1; ItemStack stack = inv.getItem(slot); String sellerString = ""; if (sellerName != null && !sellerName.equals("") && !sellerName.equals("ADMIN")) { sellerString = " AND playerName = '" + sellerName + "'"; } int orderType = 0; String priceOrder = "ASC"; String per = "perItems"; String perGroup = ", perItems"; if (inv.getName().equals("<Broker> Buy Orders") || inv.getName().equals("<Broker> Buy Cancel") || inv.getName().equals("<Broker> Buy AdminCancel")) { orderType = 1; priceOrder = "DESC"; per = "SUM(quant) AS perItems"; perGroup = ""; } HashMap<Integer, HashMap<String, Object>> orders = plugin.brokerDb.select("price, " + per, "BrokerOrders", "orderType = " + orderType + sellerString + " AND itemName = '" + stack.getType().name() + "'", "price"+perGroup+", damage, enchantments, meta", "price/perItems "+priceOrder+", damage ASC"); if (!orders.isEmpty()) { int counter = 0; for (HashMap<String, Object> order : orders.values()) { if (counter == slot) { price = Double.parseDouble(order.get("price")+""); perItems = Integer.parseInt(order.get("perItems")+""); } counter++; } } return price+":"+perItems; } @EventHandler (priority = EventPriority.NORMAL) public void onPlayerLogin(PlayerJoinEvent event) { Player player = event.getPlayer(); HashMap<Integer, HashMap<String, Object>> orders = plugin.brokerDb.select("*", "BrokerPending", "playerName = '"+player.getName()+"'", null, null); if (!orders.isEmpty()) { for (Integer orderId : orders.keySet()) { HashMap<String, Object> order = orders.get(orderId); int id = Integer.parseInt(order.get("id").toString()); Material mat = Material.getMaterial(order.get("itemName").toString()); ItemStack stack = new ItemStack(mat); short damage = Short.parseShort(order.get("damage").toString()); stack.setDurability(damage); int quant = Integer.parseInt(order.get("quant").toString()); stack.setAmount(quant); player.sendMessage(ChatColor.GOLD + "You bought " + ChatColor.WHITE + quant + " " + mat + ChatColor.GOLD + "!"); HashMap<Integer, ItemStack> dropped = player.getInventory().addItem(stack); if (!dropped.isEmpty()) { for (ItemStack dropStack : dropped.values()) { player.getWorld().dropItem(player.getLocation(), dropStack); } player.sendMessage(ChatColor.RED + "Not all bought items fit in your inventory! Check the floor!"); } plugin.brokerDb.query("DELETE FROM BrokerPending WHERE id = " + id); } } } }
141b8425e727be7db5b121373c147748dc15be2a
b04bd56e8afc2eb1ecbc7f97461e06c1f48a264c
/TSB_TP4/src/tsb_tp3/dao/BaseDatos.java
b3eeac98ddd77fab7cecc916da1fa5eb0d3b3a37
[]
no_license
davasqueza/tsb-trabajos-practicos
fb2dff5eaf3be3130b3063d6d84360ead0aca0cc
11c62b5e5db39356a95ad47e5af22609007833fd
refs/heads/master
2021-01-09T21:49:11.587874
2013-12-07T00:06:04
2013-12-07T00:06:04
46,686,774
0
0
null
null
null
null
UTF-8
Java
false
false
1,819
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package tsb_tp3.dao; import java.sql.Statement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Ale */ public class BaseDatos { private static String dbURL = "jdbc:derby:tsb_tp4_bd;create=true;user=app;password=app"; // private static String dbURL ="jdbc:derby://localhost:1527/tsb_tp3_bd"; private static Connection conn = null; private static Statement stmt = null; private BaseDatos(){} private static void conectar(){ try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); //Get a connection conn = DriverManager.getConnection(dbURL); } catch (Exception except) { except.printStackTrace(); } }; public static Connection getConexion(){ if(conn==null){ conectar(); } return conn; } public static void ejecutarSQL(String sql){ try { stmt = getConexion().createStatement(); stmt.execute(sql); stmt.close(); } catch (SQLException sqlExcept) { sqlExcept.printStackTrace(); } }; public static ResultSet ejecutarSelect(String sql){ ResultSet resultados=null; try { stmt = conn.createStatement(); resultados = stmt.executeQuery(sql); stmt.close(); } catch (SQLException sqlExcept) { sqlExcept.printStackTrace(); } return resultados; }; }
80f5d056b3637b568d09b30fdcd3ed1d3b3bc81e
3be1bd62d3dda60cd38abe9dba813dc8a693f021
/handin/code/java/client/src/infrastructure/exceptions/InvalidMessageException.java
ca1be5065271c5e4e6712ce89c2ca826d4842c18
[]
no_license
thecopy/ThorBangMQ
f10b95f9fe9c2efef897824f164524b69932be3c
8d70a9caae0b96e85b8818d03279dfae6b05cf5a
refs/heads/master
2021-01-13T01:41:51.643526
2013-12-11T16:23:08
2013-12-11T16:23:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
352
java
package infrastructure.exceptions; @SuppressWarnings("serial") public class InvalidMessageException extends Exception { public long id; public InvalidMessageException(long id) { super(); this.id = id; } public InvalidMessageException(long id, Throwable throwable) { super(throwable); this.id = id; } }
398a826b2540ed83d5f2013ff0bde73269d3c990
641101254b654db808ccb62f5ab6a22903872bf9
/wso2UserManagment/src/main/java/org/wso2/carbon/um/ws/service/dao/xsd/ExtensionMapper.java
99696aa79051d840fc27b8775f371065b64309ad
[ "Apache-2.0" ]
permissive
SunshineProject/CoreServicePlatform
4033aa43b4ff3da166774fc50eeb832324485a38
f0eea76d2fbd0361e7a81954d0b52eb8cdffef02
refs/heads/master
2021-01-10T14:08:58.633611
2016-02-17T10:34:17
2016-02-17T10:34:17
51,445,286
0
0
null
null
null
null
UTF-8
Java
false
false
3,975
java
/** * ExtensionMapper.java * * This file was auto-generated from WSDL * by the Apache Axis2 version: 1.6.2 Built on : Apr 17, 2012 (05:34:40 IST) */ package org.wso2.carbon.um.ws.service.dao.xsd; /** * ExtensionMapper class */ @SuppressWarnings({"unchecked","unused"}) public class ExtensionMapper{ public static java.lang.Object getTypeObject(java.lang.String namespaceURI, java.lang.String typeName, javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ if ( "http://core.user.carbon.wso2.org/xsd".equals(namespaceURI) && "UserStoreException".equals(typeName)){ return org.wso2.carbon.user.core.xsd.UserStoreException.Factory.parse(reader); } if ( "http://api.user.carbon.wso2.org/xsd".equals(namespaceURI) && "Tenant".equals(typeName)){ return org.wso2.carbon.user.api.xsd.Tenant.Factory.parse(reader); } if ( "http://dao.service.ws.um.carbon.wso2.org/xsd".equals(namespaceURI) && "ClaimDTO".equals(typeName)){ return org.wso2.carbon.um.ws.service.dao.xsd.ClaimDTO.Factory.parse(reader); } if ( "http://service.ws.um.carbon.wso2.org".equals(namespaceURI) && "ArrayOfString".equals(typeName)){ return org.wso2.carbon.um.ws.service.ArrayOfString.Factory.parse(reader); } if ( "http://dao.service.ws.um.carbon.wso2.org/xsd".equals(namespaceURI) && "PermissionDTO".equals(typeName)){ return org.wso2.carbon.um.ws.service.dao.xsd.PermissionDTO.Factory.parse(reader); } if ( "http://tenant.core.user.carbon.wso2.org/xsd".equals(namespaceURI) && "Tenant".equals(typeName)){ return org.wso2.carbon.user.core.tenant.xsd.Tenant.Factory.parse(reader); } if ( "http://api.user.carbon.wso2.org/xsd".equals(namespaceURI) && "RealmConfiguration".equals(typeName)){ return org.wso2.carbon.user.api.xsd.RealmConfiguration.Factory.parse(reader); } if ( "http://api.user.carbon.wso2.org/xsd".equals(namespaceURI) && "UserStoreException".equals(typeName)){ return org.wso2.carbon.user.api.xsd.UserStoreException.Factory.parse(reader); } if ( "http://common.mgt.user.carbon.wso2.org/xsd".equals(namespaceURI) && "ClaimValue".equals(typeName)){ return org.wso2.carbon.user.mgt.common.xsd.ClaimValue.Factory.parse(reader); } throw new org.apache.axis2.databinding.ADBException("Unsupported type " + namespaceURI + " " + typeName); } }
dc7ab71e1fe77f649059325af70a7c29723261b5
7783837119e1537b9c361d4163c5797e2ead6b95
/src/main/java/com/lottery/proof/reader/BaseLotteryReader.java
3c7ad55c127bb969ea7ac005f0ff5c002ad5c108
[]
no_license
ecolifr/lottery-proof-reader
fddfdccc8b559d9c885501bcb99ae93d77f595f4
f02a11433074c815530e2ee3949dfc84898ff32a
refs/heads/master
2020-03-21T16:01:17.791157
2018-06-26T14:43:58
2018-06-26T14:43:58
138,746,237
0
0
null
null
null
null
UTF-8
Java
false
false
1,345
java
package com.lottery.proof.reader; import com.lottery.dto.Lottery; import java.io.*; import java.util.ArrayList; import java.util.List; public class BaseLotteryReader { public static List<Lottery> LOTTERY = new ArrayList<>(); /** * 读取文件中选中的号码 * * @param path * @param redCount * @param blueCount */ public static void findPickNumbers(String path, final int redCount, final int blueCount) { File file = new File(path); if (!file.exists()) { System.out.printf("找不到指定文件【%s】\n", path); return; } try (FileReader fileReader = new FileReader(path); BufferedReader in = new BufferedReader(fileReader)) { LOTTERY.clear(); in.lines().forEach((String num) -> { String[] numbers = num.split(","); String[] red = new String[redCount]; String[] blue = new String[blueCount]; System.arraycopy(numbers, 0, red, 0, redCount); System.arraycopy(numbers, redCount, blue, 0, blueCount); LOTTERY.add(new Lottery(red, blue)); }); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
fe9bfc071a1dfa5e0de1caba2e3fff9d877ec7a7
a4d36c576caf67bae756d0868ccfd9cef6f825aa
/JSP/JSP WEB MVC model2 Programming/회원 리스트 보기/model/MemberBean.java
e867aada890516455d2dbd4b28eeea313b195149
[]
no_license
ps4417/TIL
5f3b2e8e4b7ccb5ed16d653ee76bf18e69f13438
91d7b9b28e1f91ad6d39828c97056b3631a9f543
refs/heads/master
2023-01-24T15:48:40.855338
2020-11-28T14:52:42
2020-11-28T14:52:42
296,226,392
0
0
null
null
null
null
UTF-8
Java
false
false
1,190
java
package model; public class MemberBean { private String id; private String pass1; private String pass2; private String email; private String tel; private String hobby; private String job; private String age; private String info; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getPass1() { return pass1; } public void setPass1(String pass1) { this.pass1 = pass1; } public String getPass2() { return pass2; } public void setPass2(String pass2) { this.pass2 = pass2; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getTel() { return tel; } public void setTel(String tel) { this.tel = tel; } public String getHobby() { return hobby; } public void setHobby(String hobby) { this.hobby = hobby; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getInfo() { return info; } public void setInfo(String info) { this.info = info; } }
b016c0e234f15f18f7d71d05999ddceb1d5dc030
d62c66c997d74bedb7033baf3eeabf42bfe140e3
/src/test/java/seedu/address/model/tutor/UniqueTutorListTest.java
e9e297ff71f33546aa3982c52231ba0c5cfbe649
[ "MIT" ]
permissive
AY2021S2-CS2103-T14-3/tp
a47b108233d4002340788803bcd4f5c874c97eac
7cf28c79401102ef1aaa0cefd03fb9dbfc5e8ace
refs/heads/master
2023-04-02T02:18:58.710283
2021-04-12T15:43:40
2021-04-12T15:43:40
338,757,833
1
5
NOASSERTION
2021-04-12T15:43:41
2021-02-14T08:10:21
Java
UTF-8
Java
false
false
6,509
java
package seedu.address.model.tutor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalTutors.ALICE; import static seedu.address.testutil.TypicalTutors.BOB; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; import seedu.address.model.tutor.exceptions.DuplicateTutorException; import seedu.address.model.tutor.exceptions.TutorNotFoundException; import seedu.address.testutil.TutorBuilder; public class UniqueTutorListTest { private final UniqueTutorList uniqueTutorList = new UniqueTutorList(); @Test public void contains_nullPerson_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.contains(null)); } @Test public void contains_personNotInList_returnsFalse() { assertFalse(uniqueTutorList.contains(ALICE)); } @Test public void contains_personInList_returnsTrue() { uniqueTutorList.add(ALICE); assertTrue(uniqueTutorList.contains(ALICE)); } @Test public void contains_personWithSameIdentityFieldsInList_returnsTrue() { uniqueTutorList.add(ALICE); Tutor editedAlice = new TutorBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); assertTrue(uniqueTutorList.contains(editedAlice)); } @Test public void add_nullPerson_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.add(null)); } @Test public void add_duplicatePerson_throwsDuplicatePersonException() { uniqueTutorList.add(ALICE); assertThrows(DuplicateTutorException.class, () -> uniqueTutorList.add(ALICE)); } @Test public void setPerson_nullTargetPerson_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.setTutor(null, ALICE)); } @Test public void setPerson_nullEditedPerson_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.setTutor(ALICE, null)); } @Test public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { assertThrows(TutorNotFoundException.class, () -> uniqueTutorList.setTutor(ALICE, ALICE)); } @Test public void setPerson_editedPersonIsSamePerson_success() { uniqueTutorList.add(ALICE); uniqueTutorList.setTutor(ALICE, ALICE); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); expectedUniqueTutorList.add(ALICE); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPerson_editedPersonHasSameIdentity_success() { uniqueTutorList.add(ALICE); Tutor editedAlice = new TutorBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); uniqueTutorList.setTutor(ALICE, editedAlice); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); expectedUniqueTutorList.add(editedAlice); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPerson_editedPersonHasDifferentIdentity_success() { uniqueTutorList.add(ALICE); uniqueTutorList.setTutor(ALICE, BOB); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); expectedUniqueTutorList.add(BOB); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { uniqueTutorList.add(ALICE); uniqueTutorList.add(BOB); assertThrows(DuplicateTutorException.class, () -> uniqueTutorList.setTutor(ALICE, BOB)); } @Test public void remove_nullPerson_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.remove(null)); } @Test public void remove_personDoesNotExist_throwsPersonNotFoundException() { assertThrows(TutorNotFoundException.class, () -> uniqueTutorList.remove(ALICE)); } @Test public void remove_existingPerson_removesPerson() { uniqueTutorList.add(ALICE); uniqueTutorList.remove(ALICE); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPersons_nullUniquePersonList_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.setTutors((UniqueTutorList) null)); } @Test public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { uniqueTutorList.add(ALICE); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); expectedUniqueTutorList.add(BOB); uniqueTutorList.setTutors(expectedUniqueTutorList); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPersons_nullList_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> uniqueTutorList.setTutors((List<Tutor>) null)); } @Test public void setPersons_list_replacesOwnListWithProvidedList() { uniqueTutorList.add(ALICE); List<Tutor> tutorList = Collections.singletonList(BOB); uniqueTutorList.setTutors(tutorList); UniqueTutorList expectedUniqueTutorList = new UniqueTutorList(); expectedUniqueTutorList.add(BOB); assertEquals(expectedUniqueTutorList, uniqueTutorList); } @Test public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { List<Tutor> listWithDuplicateTutors = Arrays.asList(ALICE, ALICE); assertThrows(DuplicateTutorException.class, () -> uniqueTutorList.setTutors(listWithDuplicateTutors)); } @Test public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { assertThrows(UnsupportedOperationException.class, () -> uniqueTutorList.asUnmodifiableObservableList().remove(0)); } }
c248a379102aefb9dee4bb2681f3bc86db112261
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/TIME-5b-3-14-NSGA_II-WeightedSum:TestLen:CallDiversity/org/joda/time/Period_ESTest_scaffolding.java
8688ac3644163e68e1e1dd195573aaea832aeedf
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
6,720
java
/** * Scaffolding file used to store all the setups needed to run * tests automatically generated by EvoSuite * Sun Jan 19 04:14:09 UTC 2020 */ package org.joda.time; import org.evosuite.runtime.annotation.EvoSuiteClassExclude; import org.junit.BeforeClass; import org.junit.Before; import org.junit.After; @EvoSuiteClassExclude public class Period_ESTest_scaffolding { @org.junit.Rule public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); @BeforeClass public static void initEvoSuiteFramework() { org.evosuite.runtime.RuntimeSettings.className = "org.joda.time.Period"; org.evosuite.runtime.GuiSupport.initialize(); org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; org.evosuite.runtime.Runtime.getInstance().resetRuntime(); } @Before public void initTestCase(){ threadStopper.storeCurrentThreads(); threadStopper.startRecordingTime(); org.evosuite.runtime.GuiSupport.setHeadless(); org.evosuite.runtime.Runtime.getInstance().resetRuntime(); org.evosuite.runtime.agent.InstrumentingAgent.activate(); } @After public void doneWithTestCase(){ threadStopper.killAndJoinClientThreads(); org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); } private static void initializeClasses() { org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(Period_ESTest_scaffolding.class.getClassLoader() , "org.joda.time.DateTimeZone", "org.joda.time.tz.DateTimeZoneBuilder$Recurrence", "org.joda.time.DateTimeUtils$MillisProvider", "org.joda.time.chrono.GJYearOfEraDateTimeField", "org.joda.time.Seconds", "org.joda.time.field.RemainderDateTimeField", "org.joda.time.JodaTimePermission", "org.joda.time.chrono.BasicWeekOfWeekyearDateTimeField", "org.joda.time.DateTimeFieldType", "org.joda.time.DateTimeFieldType$StandardDateTimeFieldType", "org.joda.time.ReadableInterval", "org.joda.time.chrono.BasicChronology$HalfdayField", "org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone", "org.joda.time.chrono.BasicChronology$YearInfo", "org.joda.time.field.UnsupportedDurationField", "org.joda.time.format.PeriodFormatterBuilder", "org.joda.time.chrono.ISOChronology", "org.joda.time.chrono.BasicChronology", "org.joda.time.chrono.BasicYearDateTimeField", "org.joda.time.format.PeriodFormatterBuilder$FieldFormatter", "org.joda.time.field.DividedDateTimeField", "org.joda.time.chrono.ZonedChronology", "org.joda.time.field.BaseDateTimeField", "org.joda.time.field.ZeroIsMaxDateTimeField", "org.joda.time.tz.CachedDateTimeZone$Info", "org.joda.time.Duration", "org.joda.time.format.FormatUtils", "org.joda.time.PeriodType", "org.joda.time.format.PeriodFormatter", "org.joda.time.field.MillisDurationField", "org.joda.time.tz.DateTimeZoneBuilder", "org.joda.time.field.UnsupportedDateTimeField", "org.joda.time.field.ScaledDurationField", "org.joda.time.chrono.ISOYearOfEraDateTimeField", "org.joda.time.ReadWritablePeriod", "org.joda.time.field.PreciseDurationDateTimeField", "org.joda.time.MutablePeriod", "org.joda.time.base.BasePeriod$1", "org.joda.time.tz.FixedDateTimeZone", "org.joda.time.format.PeriodPrinter", "org.joda.time.tz.CachedDateTimeZone", "org.joda.time.field.PreciseDateTimeField", "org.joda.time.format.PeriodFormatterBuilder$Literal", "org.joda.time.format.PeriodParser", "org.joda.time.base.BaseDuration", "org.joda.time.field.DecoratedDateTimeField", "org.joda.time.field.OffsetDateTimeField", "org.joda.time.chrono.GJMonthOfYearDateTimeField", "org.joda.time.chrono.BasicWeekyearDateTimeField", "org.joda.time.Days", "org.joda.time.DateTimeField", "org.joda.time.field.FieldUtils", "org.joda.time.base.AbstractPeriod", "org.joda.time.ReadableInstant", "org.joda.time.DateTimeUtils$SystemMillisProvider", "org.joda.time.chrono.GJDayOfWeekDateTimeField", "org.joda.time.base.BaseSingleFieldPeriod", "org.joda.time.IllegalInstantException", "org.joda.time.IllegalFieldValueException", "org.joda.time.tz.DefaultNameProvider", "org.joda.time.tz.Provider", "org.joda.time.field.ImpreciseDateTimeField$LinkedDurationField", "org.joda.time.ReadablePeriod", "org.joda.time.chrono.ZonedChronology$ZonedDateTimeField", "org.joda.time.chrono.GregorianChronology", "org.joda.time.chrono.AssembledChronology$Fields", "org.joda.time.DurationFieldType", "org.joda.time.tz.NameProvider", "org.joda.time.Minutes", "org.joda.time.chrono.BasicMonthOfYearDateTimeField", "org.joda.time.DateTimeUtils", "org.joda.time.base.AbstractDuration", "org.joda.time.Hours", "org.joda.time.base.BasePeriod", "org.joda.time.field.DecoratedDurationField", "org.joda.time.tz.DateTimeZoneBuilder$DSTZone", "org.joda.time.chrono.AssembledChronology", "org.joda.time.format.ISOPeriodFormat", "org.joda.time.tz.ZoneInfoProvider", "org.joda.time.chrono.GJEraDateTimeField", "org.joda.time.DateTimeZone$1", "org.joda.time.chrono.BaseChronology", "org.joda.time.field.ImpreciseDateTimeField", "org.joda.time.field.PreciseDurationField", "org.joda.time.Period", "org.joda.time.tz.DateTimeZoneBuilder$OfYear", "org.joda.time.ReadableDuration", "org.joda.time.chrono.BasicGJChronology", "org.joda.time.DurationField", "org.joda.time.Weeks", "org.joda.time.Chronology", "org.joda.time.format.PeriodFormatterBuilder$Composite", "org.joda.time.format.PeriodFormatterBuilder$PeriodFieldAffix", "org.joda.time.format.PeriodFormatterBuilder$SimpleAffix", "org.joda.time.chrono.BasicDayOfMonthDateTimeField", "org.joda.time.chrono.ZonedChronology$ZonedDurationField", "org.joda.time.format.PeriodFormatterBuilder$Separator", "org.joda.time.ReadablePartial", "org.joda.time.DurationFieldType$StandardDurationFieldType", "org.joda.time.chrono.BasicDayOfYearDateTimeField", "org.joda.time.field.BaseDurationField" ); } }
03049c5e8e4204338a086c7f053fec6d89695683
82f7cdced4cb9eca0c2ba0aff3f85886757d6694
/Hangman/src/Dictionary.java
66744346eff1954c9d670b5962d3c4a379e221f1
[]
no_license
spencerlachance/hangman
a3d59652569eb89fc4d4b26e20a37712a89e14a2
ea5582939672995038623e3c78202770cc4e001e
refs/heads/master
2021-08-09T01:28:35.269598
2017-11-11T19:53:42
2017-11-11T19:53:42
110,371,065
0
0
null
null
null
null
UTF-8
Java
false
false
3,558
java
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Random; /** * The Dictionary class models getting a random word from a list of words. * @author Mark Jones */ public class Dictionary { /** Create a dictionary. Default constructor uses a default (internal) dictionary. */ public Dictionary() { dictionary = new String[] { "algorithm", "application", "bus", "byte", "computer", "database", "hard disk", "keyboard", "memory", "modem", "monitor", "mouse", "network", "operating system", "program", "software", "hardware" }; numWords = dictionary.length; } /** * Create a dictionary from a file containing a list of words. * @param filename filename of the file containing the dictionary */ public Dictionary(String filename) { readDictionary(filename); } /** * Reads a dictionary from filename. * @param filename the dictionary filename containing a list of hangman words or phrases */ public void readDictionary(String filename) { try { File file = new File(filename); @SuppressWarnings("resource") Scanner sc = new Scanner(file); while (sc.hasNextLine()) { String word = sc.nextLine(); addWord(word); } } catch (FileNotFoundException e) { System.out.println("Dictionary file not found:" + e); } } /** * Gets the current number of words in the dictionary. * @return the number of words in the dictionary */ public int size() { return numWords; } /** Prints the entire dictionary. */ public void printDictionary() { printDictionary(size()); } /** * Print the first or last entries in the dictionary. * if numEntries >= 0 then print the first numEntries * if numEntries < 0 then print the last numEntries * @param numEntries number of entries to print */ public void printDictionary(int numEntries) { int begin, end; if (numEntries >= 0) { begin = 0; end = Math.min(size(), numEntries); } else { // numEntries < 0 begin = Math.max(0, numEntries + size()); end = size(); } for (int i=begin; i<end; i++) { System.out.println(i + ".\t" + dictionary[i]); } } /** * Prints front words from the front of the dictionary and * back words from the back of the dictionary. * @param front * @param back */ public void printDictionary(int front, int back) { front = Math.min(front,size()); back = Math.min(back, size()-front); printDictionary(front); System.out.println(". . ."); printDictionary(-back); } /** * Appends a word to the end of the dictionary. * @param word */ public void addWord(String word) { if (numWords < MAX_WORDS) { dictionary[numWords] = word; numWords++; } } /** * Returns the ith word in the dictionary. * @param i * @return the ith word */ public String getWord(int i) { if (dictionary[i].length() < 11) return dictionary[i]; else { return getWord(i+1); } } /** * Returns a random word in the dictionary. * @return a random word */ public String getRandomWord() { return getWord(randomNumber.nextInt(numWords)); } /* class constants */ private static final int MAX_WORDS = 263533; private static Random randomNumber = new Random(); /* instance variables */ private String[] dictionary = new String[MAX_WORDS]; private int numWords = 0; }
be10dfab3c8de7bc1fede5aca0bbd51c28998354
487b9d1f0dac9fe0df62e2812db9d6a3b65a0f92
/90_SubsetsWithDup.java
914bc0197f783a1061a3250d9c798091f1b0879d
[]
no_license
qu4rkb17/LeetCode
a429b4c8ce598fbad749d52fb864c56b90d57bfa
4bf9b27450c676a9f95b356c36ce9440b0b9bd8b
refs/heads/master
2020-03-31T11:40:49.954792
2020-02-22T07:53:06
2020-02-22T07:53:06
152,186,500
0
0
null
null
null
null
UTF-8
Java
false
false
1,194
java
public List<List<Integer>> subsetsWithDup(int[] nums){ List<List<Integer>> ans = new ArrayList<>(); Arrays.sort(nums); getAns(nums, 0, new ArrayList<>(), ans); return ans; } private void getAns(int[] nums, int start, ArrayList<Integer> temp, List<List<Integer>> ans){ ans.add(new ArrayList<>(temp)); for (int i = start; i < nums.length; i++){ if (i > start && nums[i] == nums[i - 1]){ continue; } temp.add(nums[i]); getAns(nums, i + 1, temp, ans); temp.remove(temp.size() - 1); } } // public List<List<Integer>> subsetsWithDup(int[] nums) { List<List<Integer>> ans = new ArrayList<>(); ans.add(new ArrayList<>()); Arrays.sort(nums); int start = 1; for (int i = 0; i < nums.length; i++) { List<List<Integer>> ans_tmp = new ArrayList<>(); for (int j = 0; j < ans.size(); j++) { List<Integer> list = ans.get(j); if (i > 0 && nums[i] == nums[i - 1] && j < start) { continue; } List<Integer> tmp = new ArrayList<>(list); tmp.add(nums[i]); ans_tmp.add(tmp); } start = ans.size(); ans.addAll(ans_tmp); } return ans; }
0aa6f60a8da53fb0776e17525bc743496ace64ce
2a05eba4a478fbea943a1c3dce73fde60c77dacf
/system-design/src/deckOfCard/Card.java
7f0fb65f3f25a892aa6f8ef7a01117eefa918b24
[]
no_license
WATANAPEI/learning
7f79c12f760aa75410f65ddcbdad665d0c3bbeea
ecbe85f291c08d68250ca5d9a6a8000f16e96dc4
refs/heads/master
2023-06-24T04:07:47.087495
2023-06-19T04:51:36
2023-06-19T04:51:36
166,551,199
0
0
null
2023-01-19T15:18:25
2019-01-19T13:43:43
C++
UTF-8
Java
false
false
358
java
package deckOfCard; public abstract class Card implements Comparable<NormalCard> { protected Mark mark; public Card(Mark mark) { this.mark = mark; } public Mark getMark() { return this.mark; } abstract public int getNumber(); abstract public boolean equals(Card other); abstract public String toString(); }
42c81cc4e0e1bceadc9df7879f47caaf3a4df408
8dd89f9ffcc5620ae6b60f31ad47411a79a38003
/com-lawinfo-admin/src/main/java/com/lawinfo/admin/spring/MyStringHttpMessageConverter.java
ab004bbcaa82998c0a49e74861e5a69fa87b670d
[]
no_license
itface/lawinfo
496002d619ae6d14ae69d674907a6a39d0b46628
1c5202daaed8058f3c61bba986a671a9f7b12a5a
refs/heads/master
2020-04-12T01:41:35.189787
2015-10-26T06:02:07
2015-10-26T06:02:07
44,056,734
0
0
null
null
null
null
UTF-8
Java
false
false
3,155
java
package com.lawinfo.admin.spring; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; import org.springframework.http.MediaType; import org.springframework.http.converter.AbstractHttpMessageConverter; import org.springframework.util.FileCopyUtils; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; /** * Created by wangrongtao on 15-1-14. */ public class MyStringHttpMessageConverter extends AbstractHttpMessageConverter<String> { public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); private final List<Charset> availableCharsets; private boolean writeAcceptCharset = true; public MyStringHttpMessageConverter() { super(new MediaType("text", "plain", DEFAULT_CHARSET), MediaType.ALL); this.availableCharsets = new ArrayList<Charset>(Charset.availableCharsets().values()); } /** * Indicates whether the {@code Accept-Charset} should be written to any outgoing query. * <p>Default is {@code true}. */ public void setWriteAcceptCharset(boolean writeAcceptCharset) { this.writeAcceptCharset = writeAcceptCharset; } @Override public boolean supports(Class<?> clazz) { return String.class.equals(clazz); } @Override protected String readInternal(Class clazz, HttpInputMessage inputMessage) throws IOException { Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType()); return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset)); } @Override protected Long getContentLength(String s, MediaType contentType) { Charset charset = getContentTypeCharset(contentType); try { return (long) s.getBytes(charset.name()).length; } catch (UnsupportedEncodingException ex) { // should not occur throw new InternalError(ex.getMessage()); } } @Override protected void writeInternal(String s, HttpOutputMessage outputMessage) throws IOException { if (writeAcceptCharset) { outputMessage.getHeaders().setAcceptCharset(getAcceptedCharsets()); } Charset charset = getContentTypeCharset(outputMessage.getHeaders().getContentType()); FileCopyUtils.copy(s, new OutputStreamWriter(outputMessage.getBody(), charset)); } /** * Return the list of supported {@link Charset}. * * <p>By default, returns {@link Charset#availableCharsets()}. Can be overridden in subclasses. * * @return the list of accepted charsets */ protected List<Charset> getAcceptedCharsets() { return this.availableCharsets; } private Charset getContentTypeCharset(MediaType contentType) { if (contentType != null && contentType.getCharSet() != null) { return contentType.getCharSet(); } else { return DEFAULT_CHARSET; } } }
3f3a28d2094f2e6a127a8e446c83fd01427e1518
3fda2c4b7a238bc18830e35e0b8e30ec47dcee0a
/Spring Boot Quickstart/hello-world-data/src/main/java/com/example/helloworlddata/topic/TopicController.java
88512082a9b5be364fe5fffc2aaae16e076f6eab
[]
no_license
stormfireuttam/Java_Developer
ac7cd2669cf2873cc0ae9dcc5fbbe1cbc0fdd404
fdd6a2c10af60296c690512fc6a19bac1a71ef33
refs/heads/main
2023-02-16T11:15:32.821582
2021-01-16T16:14:11
2021-01-16T16:14:11
327,317,291
0
0
null
null
null
null
UTF-8
Java
false
false
1,421
java
package com.example.helloworlddata.topic; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController public class TopicController { @Autowired private TopicService topicService; //Method to get all topics @RequestMapping("/topics") public List<Topic> getAllTopics() { return topicService.getAllTopics(); } //Method to get a particular com.example.helloworlddata.topic on the basis of its id @RequestMapping("/topics/{id}") public Topic getTopic(@PathVariable String id) { return topicService.getTopic(id); } //Method to post a particular com.example.helloworlddata.topic @RequestMapping(method = RequestMethod.POST, value = "/topics") public void addTopic(@RequestBody Topic topic) { topicService.addTopic(topic); } //Method to update a com.example.helloworlddata.topic @RequestMapping(method = RequestMethod.PUT, value = "/topics/{id}") public void putTopic(@RequestBody Topic topic, @PathVariable String id) { topicService.updateTopic(id, topic); } //Method to delete a com.example.helloworlddata.topic @RequestMapping(method = RequestMethod.DELETE, value = "/topics/{id}") public void deleteTopic(@PathVariable String id) { topicService.delete(id); } }
56f3a535f5ab9048031a1f4e2addb7f0f5165db2
b46c87c352ba220e1a961e1338d009e4fcbca2b0
/app/src/main/java/com/example/ltc20/showgoltc1_4_4.java
d7e3ff0d24081e4dcedf24756dc1f82fd461ac9d
[]
no_license
gggg4209/ltc1
0ed6fec94d36ff6425f1b4e96ca0e7f4de240994
17ad3c09535275f13b3d90f104cfbe3fcbd91c44
refs/heads/master
2023-01-13T23:06:22.760849
2020-11-18T19:45:50
2020-11-18T19:45:50
314,040,754
0
0
null
null
null
null
UTF-8
Java
false
false
1,945
java
package com.example.ltc20; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; public class showgoltc1_4_4 extends AppCompatActivity { Button bt_map, bt_landmark, bt_room; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_showgoltc1_4_4); bt_map = findViewById(R.id.bt_map); bt_landmark = findViewById(R.id.bt_landmark); bt_room = findViewById(R.id.bt_room); bt_room.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(showgoltc1_4_4.this, ltc1_4_4.class);// หน้าที่กดไป startActivity(i); } }); bt_landmark.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(showgoltc1_4_4.this, landmark1.class);// หน้าที่กดไป startActivity(i); } }); bt_map.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String lat = "18.572819"; // ละติจูดสมมุติ String lng = "98.999271"; String strUri = "http://maps.google.com/maps?q=loc:" + lat + "," + lng + " (" + "Label which you want" + ")"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + lat + "," + lng)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }); } }
8fda086fe9160440b8abb16989f59335b379492a
4e5b9f4918a7e6ae2d5cfa9177ba4bbdd93804e4
/src/main/java/BestExmaples/hardTest/classes/StrungOut.java
88f784b4240a4050c1294fcfa5ddd8eee7405cea
[]
no_license
StanislavShestakov/Puzzlers1
bf935a721ab78d1ed639301f4265c632e4e19f8f
7d9d085fd93a86b80a1e16a54b881d26a47e60ff
refs/heads/master
2020-12-18T09:22:37.779304
2020-10-02T09:35:05
2020-10-02T09:35:05
235,327,048
0
0
null
null
null
null
UTF-8
Java
false
false
454
java
package BestExmaples.hardTest.classes; public class StrungOut { public static void main(String[] args) { String s = new String("Hello world!"); System.out.println(s); } public static class FadeToBlack { } } //class String { // private final java.lang.String s; // // public String(java.lang.String s) { // this.s = s; // } // // // public java.lang.String toString(){ // return s; // } //}
9720545eabe42a76887c9cdf8ecf9536ca8a64ee
e699ab7bbe1f801329dd8349009bd23069855c8e
/src/main/java/cn/hellobike/hippo/exception/BaseException.java
e32a17b6bb91354f7502cf73f7e7584ed654287b
[]
no_license
Jntmkk/easy-yapi-core
0b22a7a5f5af908c88d7d262260a78f3f681c36a
92feaa9dbde6f1ac0ebbbd6da8958b341388b19f
refs/heads/main
2023-05-23T23:44:56.309243
2021-06-20T18:39:07
2021-06-20T18:39:07
374,261,507
0
0
null
null
null
null
UTF-8
Java
false
false
294
java
package cn.hellobike.hippo.exception; import lombok.Data; /** * @Auther: [email protected] * @Date: 2021/5/29 22:12 * @Description: */ @Data public class BaseException extends Exception { public BaseException() { } public BaseException(String message) { super(message); } }
4041c54b7d31f229387b0a6857715ed2d7775c2b
8bdd62ad02c50431777ef5a068712d3f305d71a4
/src/domain/algo/bits/MaximizingXOR.java
17090475f1d759dce27476a6285acec9aabb8b2b
[]
no_license
nipunsaini-zz/HackerRank
921ca5245a3e92da72fb5418018b9710ceef2761
9a98bcb515dca7488252a42daeba088f06bcc07d
refs/heads/master
2021-06-15T18:15:27.854733
2017-04-11T07:39:19
2017-04-11T07:39:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
564
java
package domain.algo.bits; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class MaximizingXOR { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int L = Integer.parseInt(br.readLine().trim()); int M = Integer.parseInt(br.readLine().trim()); int max = 0; for(int i = L; i < M; i++){ for(int j = L+1; j <= M; j++){ int xor = i ^ j; if(xor > max) max = xor; } } System.out.println(max); } }
cd84bb05cfa11b401f0ce20359a0e19f54249cc9
1a67849d34d752d0eb06630ee7314e32d7db511d
/rx-java/rxgrpc-tck/src/test/java/com/salesforce/rxgrpc/tck/RxGrpcPublisherManyToManyFusedVerificationTest.java
9c8ea06b37d57190b6a6616a172c4ceb335dfc44
[ "BSD-3-Clause" ]
permissive
OlegDokuka/reactive-grpc
106146d166b6037073a2d3c39ad52036a50c5b89
03735af761c70068553942be94038e5928cd77e5
refs/heads/master
2020-03-25T08:21:27.790846
2019-02-13T22:50:13
2019-02-14T00:15:24
143,608,529
0
0
BSD-3-Clause
2018-08-05T11:52:37
2018-08-05T11:52:37
null
UTF-8
Java
false
false
2,808
java
/* * Copyright (c) 2017, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ package com.salesforce.rxgrpc.tck; import io.grpc.ManagedChannel; import io.grpc.Server; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; import io.reactivex.Flowable; import org.reactivestreams.Publisher; import org.reactivestreams.tck.PublisherVerification; import org.reactivestreams.tck.TestEnvironment; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Publisher tests from the Reactive Streams Technology Compatibility Kit. * https://github.com/reactive-streams/reactive-streams-jvm/tree/master/tck */ @SuppressWarnings("Duplicates") @Test(timeOut = 3000) public class RxGrpcPublisherManyToManyFusedVerificationTest extends PublisherVerification<Message> { public static final long DEFAULT_TIMEOUT_MILLIS = 500L; public static final long PUBLISHER_REFERENCE_CLEANUP_TIMEOUT_MILLIS = 1000L; public RxGrpcPublisherManyToManyFusedVerificationTest() { super(new TestEnvironment(DEFAULT_TIMEOUT_MILLIS, DEFAULT_TIMEOUT_MILLIS), PUBLISHER_REFERENCE_CLEANUP_TIMEOUT_MILLIS); } private static Server server; private static ManagedChannel channel; @BeforeClass public static void setup() throws Exception { System.out.println("RxGrpcPublisherManyToManyVerificationTest"); server = InProcessServerBuilder.forName("RxGrpcPublisherManyToManyVerificationTest").addService(new FusedTckService()).build().start(); channel = InProcessChannelBuilder.forName("RxGrpcPublisherManyToManyVerificationTest").usePlaintext().build(); } @AfterClass public static void tearDown() throws Exception { channel.shutdown(); server.shutdown(); server = null; channel = null; } @Override public Publisher<Message> createPublisher(long elements) { RxTckGrpc.RxTckStub stub = RxTckGrpc.newRxStub(channel); Flowable<Message> request = Flowable.range(0, (int)elements).map(this::toMessage); Publisher<Message> publisher = request.compose(stub::manyToMany); return publisher; } @Override public Publisher<Message> createFailedPublisher() { RxTckGrpc.RxTckStub stub = RxTckGrpc.newRxStub(channel); Flowable<Message> request = Flowable.just(toMessage(TckService.KABOOM)); Publisher<Message> publisher = request.compose(stub::manyToMany); return publisher; } private Message toMessage(int i) { return Message.newBuilder().setNumber(i).build(); } }
278596bb5a83dd2c7bdc22c40658932d7bb20f6e
2e13c9465449bf582223aaa4e889181d1b0407cb
/plugins/org.polymap.rhei.batik/src/org/polymap/rhei/batik/toolkit/TextProposalDecorator.java
ecd098ba535223806a4cb68f6d782b7ca5078a0d
[]
no_license
Polymap4/polymap4-rhei
26ed476882ea354b4276ab9d422675f73af60444
26d861e80791ff5124693d1e75f414cc22e76060
refs/heads/develop-rap2.3
2021-01-20T10:32:44.868537
2018-05-02T14:23:57
2018-05-02T14:23:57
29,816,532
0
3
null
2016-06-08T21:53:12
2015-01-25T14:23:45
Java
UTF-8
Java
false
false
8,715
java
/* * polymap.org * Copyright (C) 2014-2016, Falko Bräutigam. All rights reserved. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 3.0 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.polymap.rhei.batik.toolkit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Text; import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.fieldassist.ContentProposalAdapter; import org.eclipse.jface.fieldassist.IContentProposal; import org.eclipse.jface.fieldassist.IContentProposalListener; import org.eclipse.jface.fieldassist.IContentProposalProvider; import org.eclipse.jface.fieldassist.IControlContentAdapter; import org.eclipse.jface.fieldassist.SimpleContentProposalProvider; import org.eclipse.jface.fieldassist.TextContentAdapter; import org.eclipse.core.runtime.IProgressMonitor; import org.polymap.core.runtime.UIJob; import org.polymap.core.runtime.config.Check; import org.polymap.core.runtime.config.Config2; import org.polymap.core.runtime.config.Configurable; import org.polymap.core.runtime.config.DefaultBoolean; import org.polymap.core.runtime.config.DefaultInt; import org.polymap.core.runtime.config.Immutable; import org.polymap.core.runtime.config.NumberRangeValidator; /** * Decorates a {@link Text} widget with a proposal popup. * <p/> * The proposals are supplied by the abstract * {@link #proposals(String, int, IProgressMonitor)} method which is called from * within an {@link UIJob}. * * @author <a href="http://www.polymap.de">Falko Bräutigam</a> */ public abstract class TextProposalDecorator extends Configurable { private final static Log log = LogFactory.getLog( TextProposalDecorator.class ); /** * True specifies that a {@link SWT#Selection} event is send to the Text control. * For {@link AbstractSearchField} this triggers the search to be performed. */ @DefaultBoolean( true ) public Config2<TextProposalDecorator,Boolean> eventOnAccept; /** * The delay before the proposal job gets started. So, the time the popup is * opened actually is the the delay + proposal job execution time. */ @DefaultInt( 750 ) @Check( value=NumberRangeValidator.class, args={"0","10000"} ) public Config2<TextProposalDecorator,Integer> activationDelayMillis; /** * By default the popup size is calculated based on the shell. This may cause * problems as the shell is layouted which forces the popup to immediately close. * Setting the popup size may help. * <p/> * This property can be set only once, right after the construction of this * {@link TextProposalDecorator}. */ @Immutable public Config2<TextProposalDecorator,Point> popupSize; private Text control; private SimpleContentProposalProvider proposalProvider; private XContentProposalAdapter proposal; protected String currentSearchTxtValue; public TextProposalDecorator( Text control ) { this.control = control; // proposal proposalProvider = new SimpleContentProposalProvider( new String[0] ); proposalProvider.setFiltering( false ); TextContentAdapter controlAdapter = new TextContentAdapter() { public void insertControlContents( @SuppressWarnings("hiding") Control control, String text, int cursorPosition ) { ((Text)control).setText( text ); ((Text)control).setSelection( text.length() ); } }; proposal = new XContentProposalAdapter( control, controlAdapter, proposalProvider, null, null ); proposal.setPropagateKeys( true ); proposal.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_IGNORE ); // delay until popupSize is filled control.getDisplay().asyncExec( () -> { popupSize.ifPresent( size -> proposal.setPopupSize( size ) ); }); proposal.addContentProposalListener( new IContentProposalListener() { public void proposalAccepted( IContentProposal _proposal ) { control.setText( _proposal.getContent() + " " ); control.setSelection( _proposal.getCursorPosition()+1, _proposal.getCursorPosition()+1 ); if (eventOnAccept.get()) { Event event = new Event(); event.keyCode = SWT.Selection; event.display = control.getDisplay(); event.type = SWT.KeyUp; control.notifyListeners( SWT.KeyUp, event ); } } }); control.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent ev ) { currentSearchTxtValue = control.getText(); if (currentSearchTxtValue.length() < 1) { proposalProvider.setProposals( new String[0] ); } else { new ProposalJob().schedule( activationDelayMillis.get() ); // close popup: visual feedback for user that key has been recognized; // also, otherwise proposal would check in the current entries proposalProvider.setProposals( new String[] {} ); } } }); } public XContentProposalAdapter proposalAdapter() { return proposal; } /** * Supplies the proposals. Called from within an {@link UIJob}. * * @param text * @param monitor * @return */ protected abstract String[] proposals( String text, int maxResults, IProgressMonitor monitor ); /** * Updates the ...? */ class ProposalJob extends UIJob { private String value = control.getText(); public ProposalJob() { super( "Proposals" ); } @Override protected void runWithException( IProgressMonitor monitor ) throws Exception { // skip if control is disposed or no longer focused if (control == null || control.isDisposed()) { log.info( "Control is disposed." ); return; } // skip if search text has changed if (value != currentSearchTxtValue) { log.info( "Search text has changed: " + value + " -> " + currentSearchTxtValue ); return; } // find proposals final String[] results = proposals( value, 10, monitor ); // display control.getDisplay().asyncExec( () -> { if (!control.isFocusControl()) { log.info( "Control is no longer focused." ); return; } proposal.closeProposalPopup(); proposalProvider.setProposals( results ); if (results.length > 0 && !results[0].equals( value )) { proposal.openProposalPopup(); //proposal.setProposalPopupFocus(); } else { //proposal.closeProposalPopup(); } }); } } /** * Expose some protected methods. */ public static class XContentProposalAdapter extends ContentProposalAdapter { public XContentProposalAdapter( Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters ) { super( control, controlContentAdapter, proposalProvider, keyStroke, autoActivationCharacters ); } @Override public void closeProposalPopup() { super.closeProposalPopup(); } @Override public void openProposalPopup() { super.openProposalPopup(); } } }
92d4980aa319b0cb6ff67484f2c43379e21064ae
5e21bcb9e31621b6f5b2d53a8ec8ce7196c1958e
/bigSpring/src/main/java/com/annotation/RoutingInjected.java
d8a5cce1c794933fa966f1435604815c9b543a2d
[]
no_license
doublecancel/practice1
d4bdfc11908a3028f8380c972e68772982842615
58e788c190c7ec103787f3dadce94c96a3dd201d
refs/heads/master
2020-03-17T13:51:48.326886
2018-05-17T01:44:03
2018-05-17T01:44:03
133,647,728
0
0
null
null
null
null
UTF-8
Java
false
false
391
java
package com.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Created by Administrator on 2017/9/25. */ @Target({ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface RoutingInjected { String value() default ""; }
573a460e8a9900c319b33043516d0c4e4fdf3a98
07ec84e7a32eb807e18a8708bb2dbf28672ae607
/src/main/java/store/basket/Basket.java
8a36ee4f743b6555000943fd498720bb21d28c9a
[]
no_license
antonina18/store
b41b7af946354315c990a19fdcaefd78c84d0963
7598c6ad967eb8fbb15fc68a2f9c0a15ea8007a2
refs/heads/master
2021-01-01T15:57:01.513900
2017-09-20T07:02:40
2017-09-20T07:02:40
97,739,110
0
0
null
2017-08-22T06:13:31
2017-07-19T16:35:21
Java
UTF-8
Java
false
false
713
java
package store.basket; import com.fasterxml.jackson.annotation.JsonUnwrapped; import org.springframework.stereotype.Component; import store.item.Item; import java.util.HashMap; import java.util.Map; @Component public class Basket { @JsonUnwrapped private Map<Item, Integer> itemUnitMap = new HashMap<>(); public Basket() { itemUnitMap = new HashMap<>(); } public Basket add(Item item, Integer units){ itemUnitMap.merge(item, units, Integer::sum); return this; } public Map<Item, Integer> getItemUnitMap() { return itemUnitMap; } public void setItemUnitMap(Map<Item, Integer> itemUnitMap) { this.itemUnitMap = itemUnitMap; } }
5f3a4a82e22b0241b5947333adb027c9b4a3ddb3
d81067cc7373b6191267afcc361ed383b15b7dca
/keesun/src/chapter01/exercise/dao10/NConnectionMaker.java
bde6e5623f05a62b723a1fe084ede0c2fbb4b77e
[]
no_license
jsdilnam10/spring30_bykeesun
97ee5d855e2095241744d066d736d6c169d45d98
956dd3c97f8c7c09abb5aaad465ca6ac6128413e
refs/heads/master
2021-01-23T00:35:09.952980
2017-06-02T03:14:28
2017-06-02T03:14:28
92,821,442
0
0
null
null
null
null
UTF-8
Java
false
false
463
java
package chapter01.exercise.dao10; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class NConnectionMaker implements ConnectionMaker { public Connection makeConnection() throws ClassNotFoundException, SQLException { Class.forName("org.postgresql.Driver"); Connection connection = DriverManager.getConnection( "jdbc:postgresql://localhost/spring30", "spring30", "spring30"); return connection; } }
bfa3bf13582f1584bb259da345288b7bd57688c3
10e717c8d7c5e190ef530bf3adc011562f8a9e98
/helloJob/src/main/java/com/helloJob/commons/shiro/PasswordHash.java
c67450acac186290bd8c4b48740e311181da2b9c
[]
no_license
iture123/helloJob
d18e74bfc534242ff950fa82529a68dbace4088a
4895c86db62e5c4986c0c8293ce45978b9f35a27
refs/heads/dev
2022-12-13T21:42:19.662230
2019-06-20T11:43:48
2019-06-20T11:43:48
134,046,471
82
32
null
2022-11-16T08:23:12
2018-05-19T09:01:59
JavaScript
UTF-8
Java
false
false
1,018
java
package com.helloJob.commons.shiro; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; import com.helloJob.commons.utils.DigestUtils; /** * shiro密码加密配置 * @author L.cm * */ public class PasswordHash implements InitializingBean { private String algorithmName; private int hashIterations; public String getAlgorithmName() { return algorithmName; } public void setAlgorithmName(String algorithmName) { this.algorithmName = algorithmName; } public int getHashIterations() { return hashIterations; } public void setHashIterations(int hashIterations) { this.hashIterations = hashIterations; } @Override public void afterPropertiesSet() throws Exception { Assert.hasLength(algorithmName, "algorithmName mast be MD5、SHA-1、SHA-256、SHA-384、SHA-512"); } public String toHex(Object source, Object salt) { return DigestUtils.hashByShiro(algorithmName, source, salt, hashIterations); } }
350ab64d7f445942bd9c58a20baad13e7632f581
8833b7cbcc57dd0efa8683a6f4c7e50543d9d717
/src/main/java/cn/wanru/user/repo/UserRepo.java
6cdbd4a11f5f8aa03d5bb94e7b9143b5c88659e1
[]
no_license
xianfengxiong/spring-template
e0f53a43075bdd32f2918daec9310d82cda123a9
df2b79b8d5e0b6ccd24ee15211bca2ed5c59d104
refs/heads/master
2021-01-12T06:43:00.483696
2017-02-04T10:17:58
2017-02-04T10:17:58
77,419,908
0
0
null
null
null
null
UTF-8
Java
false
false
229
java
package cn.wanru.user.repo; import cn.wanru.user.entity.User; import org.springframework.data.jpa.repository.JpaRepository; /** * @author xxf * @since 2/4/17 */ public interface UserRepo extends JpaRepository<User,Long> { }
e78797438c86124954aff7885e062ee4de535e83
2618e90f471ab77bf1a29eba6f50386a1513e736
/WebService/src/playground/IteratorTest.java
65b815a3bac6bc2ea187f0e81492265a7fc2d558
[]
no_license
Jeonghoon-Lee/java-workspace
8ea4dcb2c3e8f33ee72d700c2a90c4dd13f69430
0abaf3fefd04af7d25255d01a08c63fd99e43053
refs/heads/master
2020-05-28T08:51:49.493817
2019-07-19T01:26:51
2019-07-19T01:26:51
188,946,725
1
1
null
null
null
null
UTF-8
Java
false
false
1,054
java
package playground; import assignment1.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.stream.Collectors; public class IteratorTest { public static void main(String[] args) { ArrayList<Person> personList = new ArrayList<>(); personList.add(new Person(4, "Marie", "France")); personList.add(new Person(5, "Mark", "Corry")); personList.add(new Person(1, "James", "Dean")); personList.add(new Person(3, "Michael", "Jackson")); personList.add(new Person(2, "Bill", "Smith")); Iterator<Person> it = personList.iterator(); while (it.hasNext()) { if (it.next().getId() == 1) { it.remove(); } } personList.forEach(p -> System.out.println(p)); // personList = personList.stream().filter(p -> p.getId() != 3).collect(Collectors.toCollection(ArrayList::new)); personList.removeIf(p -> p.getId() == 2); personList.forEach(p -> System.out.println(p)); } }
a9a624be61d9be789d9a1a44a5ba34595819fef9
c7eea2d07d06db84431259769e641c49dc7d5f60
/src/main/java/com/crm/model/Role.java
f88b8876b4eff42f64fb3a3bfdfab0073cea4a28
[]
no_license
sebaztia/crmsys
6f4f53c2e47313c6633072b54ad45b6e50340a8c
303466d224074ead0e480263c143e7bed40cacf3
refs/heads/main
2023-02-28T20:37:36.338249
2021-02-01T16:06:36
2021-02-01T16:06:36
328,494,636
0
0
null
null
null
null
UTF-8
Java
false
false
857
java
package com.crm.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class Role { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; public Role() { } public Role(String name) { this.name = name; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Role{" + "id=" + id + ", name='" + name + '\'' + '}'; } }
b885db10e2fcf6895e5bbe4522729df8f485d5f2
9027218bfcccb31fc490b7c16f99c3938ff8cfbf
/app/src/main/java/com/release/mvvm2/ui/home/MainActivity.java
e10594a466aa0afd929303bac3462f51fb808bb2
[ "Apache-2.0" ]
permissive
enChenging/MVVM_Template2
a326fad12c619c1a87e30deb60d432507531c2b2
b4e3ec08dc7d9b30df19d028233335e12168ac15
refs/heads/master
2022-12-05T22:21:59.163452
2020-08-29T07:14:39
2020-08-29T07:14:39
289,794,022
0
0
null
null
null
null
UTF-8
Java
false
false
4,934
java
package com.release.mvvm2.ui.home; import android.os.Bundle; import android.view.KeyEvent; import android.view.MenuItem; import android.view.View; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.navigation.NavController; import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.ui.NavigationUI; import com.alibaba.android.arouter.facade.annotation.Route; import com.bumptech.glide.Glide; import com.google.android.material.navigation.NavigationView; import com.release.base.base.BaseActivity; import com.release.base.router.RouterActivityPath; import com.release.base.utils.StatusBarUtil; import com.release.base.utils.ToastUtils; import com.release.mvvm2.BR; import com.release.mvvm2.R; import com.release.mvvm2.databinding.ActivityMainBinding; import cn.jzvd.Jzvd; /** * @author Mr.release * @create 2019/3/22 * @Describe */ @Route(path = RouterActivityPath.Main.PAGER_MAIN) public class MainActivity extends BaseActivity<ActivityMainBinding, MainViewModel> implements NavigationView.OnNavigationItemSelectedListener { private static final String TAG = MainActivity.class.getSimpleName(); private ImageView mHeadImg; @Override public int getLayoutId(Bundle savedInstanceState) { return R.layout.activity_main; } @Override public int initVariableId() { return BR.viewModel; } @Override public void initView() { View headerView = binding.leftNavigation.getHeaderView(0); binding.leftNavigation.setItemIconTintList(null); mHeadImg = headerView.findViewById(R.id.headImg); binding.bottomNavigation.enableAnimation(false); NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_nav); NavController navController = navHostFragment.getNavController(); NavigationUI.setupWithNavController(binding.bottomNavigation, navController); } @Override public void initListener() { binding.dlDrawer.setScrimColor(getResources().getColor(R.color.black_alpha_32)); binding.dlDrawer.addDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { if (drawerView != null && drawerView.getTag().equals("left")) { View content = binding.dlDrawer.getChildAt(0); int offset = (int) (drawerView.getWidth() * slideOffset); content.setTranslationX(offset); } } @Override public void onDrawerOpened(View drawerView) { } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerStateChanged(int newState) { } }); binding.leftNavigation.setNavigationItemSelectedListener(this); } @Override public void updateViews(boolean isRefresh) { Glide.with(this).load("https://b-ssl.duitang.com/uploads/item/201802/20/20180220170028_JcYMU.jpeg").circleCrop().into(mHeadImg); } @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.nav_help_center: ToastUtils.show("帮助中心"); break; case R.id.nav_setting: ToastUtils.show("设置"); break; case R.id.nav_camera: ToastUtils.show("照相机"); break; case R.id.nav_gallery: ToastUtils.show("相册"); break; } toggle(); return false; } public void toggle() { viewModel.toggle(binding.dlDrawer); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { viewModel.exit(closeDrawableLayout()); return false; } return super.onKeyDown(keyCode, event); } public boolean closeDrawableLayout() { if (binding.dlDrawer.isDrawerVisible(GravityCompat.START)) { binding.dlDrawer.closeDrawer(GravityCompat.START); return true; } else { return false; } } @Override protected void setStatusBar() { StatusBarUtil.setColorForDrawerLayout(this, binding.dlDrawer, getResources().getColor(R.color.colorPrimary), 0); } @Override public void onBackPressed() { if (Jzvd.backPress()) { return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); Jzvd.resetAllVideos(); } }
1e2c8021c7e9657b84954743a74a0d41a61837f1
e12bc5133965310f1ef83f5ee67d7ca6743e6603
/app/src/main/java/com/nytimes/booksinfo/pojos/Book.java
66fb48eb669540d1c5e1f6dd66a8c3fc48ad6f9d
[]
no_license
ramyakrishna25/BookInfo
940c2474c7e3aa336f788d7a99fcf61b532ca67e
10aa6794fff69ebcfe4ed4865e6567dd4595e337
refs/heads/master
2020-05-30T17:14:30.890237
2019-06-03T07:25:32
2019-06-03T07:25:32
189,867,806
0
0
null
null
null
null
UTF-8
Java
false
false
18,973
java
package com.nytimes.booksinfo.pojos; import android.os.Parcel; import android.os.Parcelable; import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; public class Book { @SerializedName("status") @Expose private String status; @SerializedName("copyright") @Expose private String copyright; @SerializedName("num_results") @Expose private Integer numResults; @SerializedName("last_modified") @Expose private String lastModified; @SerializedName("results") @Expose private Results results; public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getCopyright() { return copyright; } public void setCopyright(String copyright) { this.copyright = copyright; } public Integer getNumResults() { return numResults; } public void setNumResults(Integer numResults) { this.numResults = numResults; } public String getLastModified() { return lastModified; } public void setLastModified(String lastModified) { this.lastModified = lastModified; } public Results getResults() { return results; } public void setResults(Results results) { this.results = results; } public static class BuyLink implements Parcelable { @SerializedName("name") @Expose private String name; @SerializedName("url") @Expose private String url; protected BuyLink(Parcel in) { name = in.readString(); url = in.readString(); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(name); dest.writeString(url); } @Override public int describeContents() { return 0; } public static final Creator<BuyLink> CREATOR = new Creator<BuyLink>() { @Override public BuyLink createFromParcel(Parcel in) { return new BuyLink(in); } @Override public BuyLink[] newArray(int size) { return new BuyLink[size]; } }; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } } public static class Books implements Parcelable { @SerializedName("rank") @Expose private Integer rank; @SerializedName("rank_last_week") @Expose private Integer rankLastWeek; @SerializedName("weeks_on_list") @Expose private Integer weeksOnList; @SerializedName("asterisk") @Expose private Integer asterisk; @SerializedName("dagger") @Expose private Integer dagger; @SerializedName("primary_isbn10") @Expose private String primaryIsbn10; @SerializedName("primary_isbn13") @Expose private String primaryIsbn13; @SerializedName("publisher") @Expose private String publisher; @SerializedName("description") @Expose private String description; @SerializedName("price") @Expose private Integer price; @SerializedName("title") @Expose private String title; @SerializedName("author") @Expose private String author; @SerializedName("contributor") @Expose private String contributor; @SerializedName("contributor_note") @Expose private String contributorNote; @SerializedName("book_image") @Expose private String bookImage; @SerializedName("book_image_width") @Expose private Integer bookImageWidth; @SerializedName("book_image_height") @Expose private Integer bookImageHeight; @SerializedName("amazon_product_url") @Expose private String amazonProductUrl; @SerializedName("age_group") @Expose private String ageGroup; @SerializedName("book_review_link") @Expose private String bookReviewLink; @SerializedName("first_chapter_link") @Expose private String firstChapterLink; @SerializedName("sunday_review_link") @Expose private String sundayReviewLink; @SerializedName("article_chapter_link") @Expose private String articleChapterLink; @SerializedName("isbns") @Expose private List<Isbn> isbns = null; @SerializedName("buy_links") @Expose private List<BuyLink> buyLinks = null; public Books(Parcel in) { if (in.readByte() == 0) { rank = null; } else { rank = in.readInt(); } if (in.readByte() == 0) { rankLastWeek = null; } else { rankLastWeek = in.readInt(); } if (in.readByte() == 0) { weeksOnList = null; } else { weeksOnList = in.readInt(); } if (in.readByte() == 0) { asterisk = null; } else { asterisk = in.readInt(); } if (in.readByte() == 0) { dagger = null; } else { dagger = in.readInt(); } primaryIsbn10 = in.readString(); primaryIsbn13 = in.readString(); publisher = in.readString(); description = in.readString(); if (in.readByte() == 0) { price = null; } else { price = in.readInt(); } title = in.readString(); author = in.readString(); contributor = in.readString(); contributorNote = in.readString(); bookImage = in.readString(); if (in.readByte() == 0) { bookImageWidth = null; } else { bookImageWidth = in.readInt(); } if (in.readByte() == 0) { bookImageHeight = null; } else { bookImageHeight = in.readInt(); } amazonProductUrl = in.readString(); ageGroup = in.readString(); bookReviewLink = in.readString(); firstChapterLink = in.readString(); sundayReviewLink = in.readString(); articleChapterLink = in.readString(); } public static final Creator<Books> CREATOR = new Creator<Books>() { @Override public Books createFromParcel(Parcel in) { return new Books(in); } @Override public Books[] newArray(int size) { return new Books[size]; } }; public Books() { } public Integer getRank() { return rank; } public void setRank(Integer rank) { this.rank = rank; } public Integer getRankLastWeek() { return rankLastWeek; } public void setRankLastWeek(Integer rankLastWeek) { this.rankLastWeek = rankLastWeek; } public Integer getWeeksOnList() { return weeksOnList; } public void setWeeksOnList(Integer weeksOnList) { this.weeksOnList = weeksOnList; } public Integer getAsterisk() { return asterisk; } public void setAsterisk(Integer asterisk) { this.asterisk = asterisk; } public Integer getDagger() { return dagger; } public void setDagger(Integer dagger) { this.dagger = dagger; } public String getPrimaryIsbn10() { return primaryIsbn10; } public void setPrimaryIsbn10(String primaryIsbn10) { this.primaryIsbn10 = primaryIsbn10; } public String getPrimaryIsbn13() { return primaryIsbn13; } public void setPrimaryIsbn13(String primaryIsbn13) { this.primaryIsbn13 = primaryIsbn13; } public String getPublisher() { return publisher; } public void setPublisher(String publisher) { this.publisher = publisher; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Integer getPrice() { return price; } public void setPrice(Integer price) { this.price = price; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getContributor() { return contributor; } public void setContributor(String contributor) { this.contributor = contributor; } public String getContributorNote() { return contributorNote; } public void setContributorNote(String contributorNote) { this.contributorNote = contributorNote; } public String getBookImage() { return bookImage; } public void setBookImage(String bookImage) { this.bookImage = bookImage; } public Integer getBookImageWidth() { return bookImageWidth; } public void setBookImageWidth(Integer bookImageWidth) { this.bookImageWidth = bookImageWidth; } public Integer getBookImageHeight() { return bookImageHeight; } public void setBookImageHeight(Integer bookImageHeight) { this.bookImageHeight = bookImageHeight; } public String getAmazonProductUrl() { return amazonProductUrl; } public void setAmazonProductUrl(String amazonProductUrl) { this.amazonProductUrl = amazonProductUrl; } public String getAgeGroup() { return ageGroup; } public void setAgeGroup(String ageGroup) { this.ageGroup = ageGroup; } public String getBookReviewLink() { return bookReviewLink; } public void setBookReviewLink(String bookReviewLink) { this.bookReviewLink = bookReviewLink; } public String getFirstChapterLink() { return firstChapterLink; } public void setFirstChapterLink(String firstChapterLink) { this.firstChapterLink = firstChapterLink; } public String getSundayReviewLink() { return sundayReviewLink; } public void setSundayReviewLink(String sundayReviewLink) { this.sundayReviewLink = sundayReviewLink; } public String getArticleChapterLink() { return articleChapterLink; } public void setArticleChapterLink(String articleChapterLink) { this.articleChapterLink = articleChapterLink; } public List<Isbn> getIsbns() { return isbns; } public void setIsbns(List<Isbn> isbns) { this.isbns = isbns; } public List<BuyLink> getBuyLinks() { return buyLinks; } public void setBuyLinks(List<BuyLink> buyLinks) { this.buyLinks = buyLinks; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { if (rank == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(rank); } if (rankLastWeek == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(rankLastWeek); } if (weeksOnList == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(weeksOnList); } if (asterisk == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(asterisk); } if (dagger == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(dagger); } dest.writeString(primaryIsbn10); dest.writeString(primaryIsbn13); dest.writeString(publisher); dest.writeString(description); if (price == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(price); } dest.writeString(title); dest.writeString(author); dest.writeString(contributor); dest.writeString(contributorNote); dest.writeString(bookImage); if (bookImageWidth == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(bookImageWidth); } if (bookImageHeight == null) { dest.writeByte((byte) 0); } else { dest.writeByte((byte) 1); dest.writeInt(bookImageHeight); } dest.writeString(amazonProductUrl); dest.writeString(ageGroup); dest.writeString(bookReviewLink); dest.writeString(firstChapterLink); dest.writeString(sundayReviewLink); dest.writeString(articleChapterLink); } } public class Isbn { @SerializedName("isbn10") @Expose private String isbn10; @SerializedName("isbn13") @Expose private String isbn13; public String getIsbn10() { return isbn10; } public void setIsbn10(String isbn10) { this.isbn10 = isbn10; } public String getIsbn13() { return isbn13; } public void setIsbn13(String isbn13) { this.isbn13 = isbn13; } } public class Results { @SerializedName("list_name") @Expose private String listName; @SerializedName("list_name_encoded") @Expose private String listNameEncoded; @SerializedName("bestsellers_date") @Expose private String bestsellersDate; @SerializedName("published_date") @Expose private String publishedDate; @SerializedName("published_date_description") @Expose private String publishedDateDescription; @SerializedName("next_published_date") @Expose private String nextPublishedDate; @SerializedName("previous_published_date") @Expose private String previousPublishedDate; @SerializedName("display_name") @Expose private String displayName; @SerializedName("normal_list_ends_at") @Expose private Integer normalListEndsAt; @SerializedName("updated") @Expose private String updated; @SerializedName("books") @Expose private List<Books> books = null; @SerializedName("corrections") @Expose private List<Object> corrections = null; public String getListName() { return listName; } public void setListName(String listName) { this.listName = listName; } public String getListNameEncoded() { return listNameEncoded; } public void setListNameEncoded(String listNameEncoded) { this.listNameEncoded = listNameEncoded; } public String getBestsellersDate() { return bestsellersDate; } public void setBestsellersDate(String bestsellersDate) { this.bestsellersDate = bestsellersDate; } public String getPublishedDate() { return publishedDate; } public void setPublishedDate(String publishedDate) { this.publishedDate = publishedDate; } public String getPublishedDateDescription() { return publishedDateDescription; } public void setPublishedDateDescription(String publishedDateDescription) { this.publishedDateDescription = publishedDateDescription; } public String getNextPublishedDate() { return nextPublishedDate; } public void setNextPublishedDate(String nextPublishedDate) { this.nextPublishedDate = nextPublishedDate; } public String getPreviousPublishedDate() { return previousPublishedDate; } public void setPreviousPublishedDate(String previousPublishedDate) { this.previousPublishedDate = previousPublishedDate; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public Integer getNormalListEndsAt() { return normalListEndsAt; } public void setNormalListEndsAt(Integer normalListEndsAt) { this.normalListEndsAt = normalListEndsAt; } public String getUpdated() { return updated; } public void setUpdated(String updated) { this.updated = updated; } public List<Books> getBooks() { return books; } public void setBooks(List<Books> books) { this.books = books; } public List<Object> getCorrections() { return corrections; } public void setCorrections(List<Object> corrections) { this.corrections = corrections; } } }
fe2624838c208a92d517b27c1e41a71b03d785c4
f9f664fade2b9936e3a450d9d0bba19fe50fbeb2
/camel-blueprint-salesforce-test/src/main/java/org/apache/camel/salesforce/dto/QueryRecordsSiteHistory.java
b6737b7ca9c39c87db1c4e71009bb809b2c0f26c
[]
no_license
1984shekhar/fuse-my-examples
78c2898c2366649504bbe22480b894d29952d2a7
761db030c603b8398ea78a18a4cb2ade1a55b34f
refs/heads/master
2022-12-07T05:03:06.826126
2019-10-13T16:21:28
2019-10-13T16:21:28
30,963,768
0
4
null
2022-11-24T03:57:27
2015-02-18T11:58:40
Java
UTF-8
Java
false
false
692
java
/* * Salesforce Query DTO generated by camel-salesforce-maven-plugin * Generated on: Wed Apr 08 20:26:47 IST 2015 */ package org.apache.camel.salesforce.dto; import com.thoughtworks.xstream.annotations.XStreamImplicit; import org.apache.camel.component.salesforce.api.dto.AbstractQueryRecordsBase; import java.util.List; /** * Salesforce QueryRecords DTO for type SiteHistory */ public class QueryRecordsSiteHistory extends AbstractQueryRecordsBase { @XStreamImplicit private List<SiteHistory> records; public List<SiteHistory> getRecords() { return records; } public void setRecords(List<SiteHistory> records) { this.records = records; } }
c9b8940748261fd94f1b658a22d0fc53d917834a
4a35c97abfa103c76280e7a5157eccb9875522e2
/demo/src/connectionSocket/inet/ConnectionListenerAdapter.java
90952c97ad2801ed515e872dad4a655c24a088fa
[]
no_license
wqser/test
82cec130d38ca9dceafcc393d7b2b411237e6db4
83b4516ae33aa27a20e44e1312fa3d168710f01e
refs/heads/master
2021-05-07T15:20:36.025772
2017-11-08T07:06:32
2017-11-08T07:06:32
109,939,713
0
0
null
null
null
null
UTF-8
Java
false
false
1,592
java
/* * Copyright (C) 2007 * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ package connectionSocket.inet; /** * This adapter class provides default implementations for the * methods declared in the <code>ConnectionListener</code> interface. * <p> * Classes that wish to deal with <code>ConnectionEvent</code>s can * extend this class and override only the methods which they are * interested in. * </p> * * @see ConnectionListener * @see ConnectionEvent */ public class ConnectionListenerAdapter implements ConnectionListener { /** * Called when connection is established. * The default behavior is to do nothing. * @param e connection event */ public void connected(ConnectedEvent e) { } /** * Called when connection is closed. * The default behavior is to do nothing. * @param e connection event */ public void disconnected(DisconnectedEvent e) { } /** * Called when packed received * The default behavior is to do nothing. * @param e connection event */ public void packetReceived(PacketReceivedEvent e) { } }
863ac77a62079ef44ac225d9bc6dfd02ae13f86c
54ec6420a202370c7ccef939888eb450369078a3
/STS/blog-pessoal/src/main/java/org/generation/blogpessoal/service/UsuarioService.java
90015c2f6a6d85d09dc51cbca4e8632083257718
[]
no_license
Leoiamur/turma11java
974421ff3d1f01530158db135f8f77e66a0dbe11
79e3616e8f4a0890584d190f1d66bcecca61b049
refs/heads/master
2023-01-13T14:23:12.983655
2020-11-16T13:20:24
2020-11-16T13:20:24
298,044,503
0
0
null
null
null
null
UTF-8
Java
false
false
1,528
java
package org.generation.blogpessoal.service; import java.nio.charset.Charset; import java.util.Optional; import org.apache.commons.codec.binary.Base64; import org.generation.blogpessoal.model.UserLogin; import org.generation.blogpessoal.model.Usuario; import org.generation.blogpessoal.repository.UsuarioRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; @Service public class UsuarioService { @Autowired private UsuarioRepository repository; public Usuario CadastrarUsuario(Usuario usuario) { BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); String senhaEncoder = encoder.encode(usuario.getSenha()); usuario.setSenha(senhaEncoder); return repository.save(usuario); } public Optional<UserLogin> Logar(Optional<UserLogin> user){ BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); Optional<Usuario> usuario = repository.findByUsuario(user.get().getUsuario()); if(usuario.isPresent()) { if(encoder.matches(user.get().getSenha(), usuario.get().getSenha())) { String auth = user.get().getUsuario() + ":" + user.get().getSenha(); byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII"))); String authHeader ="Basic " + new String(encodedAuth); user.get().setToken(authHeader); user.get().setNome(usuario.get().getNome()); return user; } } return null; } }
85a93e9ed009d4c7a475ff4b3eca9dae3bd4c6b7
da50b3b23e79a6c439b26b8588cf497a105020d3
/backend/src/main/java/com/dextra/hamburgueria/controllers/excepitons/ExceptionHandlerController.java
5f358015a44b5739b41bccc2c6c806138f597ed1
[]
no_license
s4nderx/hamburgueria
5225616f22ca556062618a216826211109056722
3ea2b7c1a2f7838694e7a1fb302bac2c6116f136
refs/heads/main
2023-03-31T03:10:19.287938
2021-04-04T13:52:39
2021-04-04T13:52:39
352,682,810
0
0
null
null
null
null
UTF-8
Java
false
false
1,875
java
package com.dextra.hamburgueria.controllers.excepitons; import com.dextra.hamburgueria.services.exception.EntityNotFoundException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.FieldError; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import javax.servlet.http.HttpServletRequest; import java.time.Instant; @ControllerAdvice public class ExceptionHandlerController { @ExceptionHandler(EntityNotFoundException.class) public ResponseEntity<StandardError> entityNotFound(EntityNotFoundException exception, HttpServletRequest request){ StandardError error = new StandardError(); error.setTimestamp(Instant.now()); error.setStatus(HttpStatus.NOT_FOUND.value()); error.setError("Resource not found"); error.setMessage(exception.getMessage()); error.setPath(request.getRequestURI()); return ResponseEntity.status(error.getStatus()).body(error); } @ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity<ValidationError> validation(MethodArgumentNotValidException exception, HttpServletRequest request){ ValidationError error = new ValidationError(); error.setTimestamp(Instant.now()); error.setStatus(HttpStatus.UNPROCESSABLE_ENTITY.value()); error.setError("Validation Exception"); error.setMessage("Campos inválidos."); error.setPath(request.getRequestURI()); for(FieldError f : exception.getBindingResult().getFieldErrors()){ error.addError(f.getField(), f.getDefaultMessage()); } return ResponseEntity.status(error.getStatus()).body(error); } }
d1170fabec5d64bda9ad81e5741bffc026017be7
055955d93bb1c6a7a8c5974742cacb902bef8af8
/app/src/main/java/me/com/butterflydemo/annotation/ButterFly.java
460174fd5f68b0238fc85e872eca0aa0529b1f90
[]
no_license
lu-xu/ButterFlyAnnotation
0ded8623bee61a805a641da1963cbc769d5a2c87
0b287f86f345ebfb613e75c2fd7124251597751e
refs/heads/master
2021-01-22T05:53:50.686262
2017-05-26T11:19:05
2017-05-26T11:19:05
92,503,281
1
0
null
null
null
null
UTF-8
Java
false
false
386
java
package me.com.butterflydemo.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Created by xulu on 2017/5/26. */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface ButterFly { int id(); String click() default ""; }
10744ef965a3acce3bb9e485fe0ad66ba1bf4d49
f57920ff686d2002e8321bf3fbb9d3f78254360f
/src/edu/ktu/ds/lab2/Jonušas/ManoTestas.java
dc74244b051cd9d4820f290a6e2d71301e651eaf
[]
no_license
5ulas/L115_IFA_8_1_Jonusas_Laurynas
17c346b8af0614fa7fb253a305cbdb9e92dcd742
9452620fb30e2b4cd86f4997c3e30a81b0f0b618
refs/heads/master
2020-09-14T22:08:51.692568
2019-11-21T22:23:15
2019-11-21T22:23:15
223,273,090
0
0
null
null
null
null
UTF-8
Java
false
false
5,322
java
package edu.ktu.ds.lab2.Jonušas; import edu.ktu.ds.lab2.utils.*; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.Locale; /* * Aibės testavimas be Gui * */ public class ManoTestas { static Person[] people; static ParsableSortedSet<Person> cSeries = new ParsableBstSet<>(Person::new, Person.byHeight); public static void main(String[] args) throws CloneNotSupportedException { Locale.setDefault(Locale.US); // Suvienodiname skaičių formatus executeTest(); } public static void executeTest() throws CloneNotSupportedException { Person c1 = new Person("zaidejas1", "pavarde1", 180, 190); Person c2 = new Person.Builder() .name("zaidejas2") .surname("pavarde2") .height(171) .weight(200) .build(); Person c3 = new Person.Builder().buildRandom(); Person c4 = new Person("Jonas Joanitis 150 51"); Person c5 = new Person("Albertas Alberas 175 75"); Person c6 = new Person("Modestas Modelinis 180 90"); Person c7 = new Person("Tomas Fiesta 199 99"); Person c8 = new Person("Laurynas Jonušas 190 90"); Person c9 = new Person("Petras Petraitis 207 307"); Person[] peopleArray = {c9, c7, c8, c5, c1, c6}; Ks.oun("Žmonių Aibė:"); ParsableSortedSet<Person> peopleSet = new ParsableBstSet<>(Person::new); for (Person c : peopleArray) { peopleSet.add(c); Ks.oun("Aibė papildoma: " + c + ". Jos dydis: " + peopleSet.size()); } Ks.oun(""); Ks.oun(peopleSet.toVisualizedString("")); ParsableSortedSet<Person> peopleSetCopy = (ParsableSortedSet<Person>) peopleSet.clone(); peopleSetCopy.add(c2); peopleSetCopy.add(c3); peopleSetCopy.add(c4); Ks.oun("Papildyta autoaibės kopija:"); Ks.oun(peopleSetCopy.toVisualizedString("")); c9.setHeight(100); Ks.oun("Originalas:"); Ks.ounn(peopleSet.toVisualizedString("")); Ks.oun("Ar elementai egzistuoja aibėje?"); for (Person c : peopleArray) { Ks.oun(c + ": " + peopleSet.contains(c)); } Ks.oun(c2 + ": " + peopleSet.contains(c2)); Ks.oun(c3 + ": " + peopleSet.contains(c3)); Ks.oun(c4 + ": " + peopleSet.contains(c4)); Ks.oun(""); Ks.oun("Ar elementai egzistuoja aibės kopijoje?"); for (Person c : peopleArray) { Ks.oun(c + ": " + peopleSetCopy.contains(c)); } Ks.oun(c2 + ": " + peopleSetCopy.contains(c2)); Ks.oun(c3 + ": " + peopleSetCopy.contains(c3)); Ks.oun(c4 + ": " + peopleSetCopy.contains(c4)); Ks.oun(""); Ks.oun("Elementų šalinimas iš kopijos. Aibės dydis prieš šalinimą: " + peopleSetCopy.size()); for (Person c : new Person[]{c2, c1, c9, c8, c5, c3, c4, c2, c7, c6, c7, c9}) { peopleSetCopy.remove(c); Ks.oun("Iš Žmonių aibės kopijos pašalinama: " + c + ". Jos dydis: " + peopleSetCopy.size()); } Ks.oun(""); Ks.oun("Žmonių aibė su iteratoriumi:"); Ks.oun(""); for (Person c : peopleSet) { Ks.oun(c); } Ks.oun(""); Ks.oun("Žmonių aibė AVL-medyje:"); ParsableSortedSet<Person> peopleSetAVL = new ParsableAvlSet<>(Person::new); for (Person c : peopleArray) { peopleSetAVL.add(c); } Ks.ounn(peopleSetAVL.toVisualizedString("")); Ks.oun("Žmonių aibė su iteratoriumi:"); Ks.oun(""); for (Person c : peopleSetAVL) { Ks.oun(c); } Ks.oun(""); Ks.oun("Žmonių aibė su atvirkštiniu iteratoriumi:"); Ks.oun(""); Iterator iter = peopleSetAVL.descendingIterator(); while (iter.hasNext()) { Ks.oun(iter.next()); } Ks.oun(""); Ks.oun("Žmonių aibės toString() metodas:"); Ks.ounn(peopleSetAVL); // Išvalome ir suformuojame aibes skaitydami iš failo peopleSet.clear(); peopleSetAVL.clear(); Ks.oun(""); Ks.oun("Žmonių aibė DP-medyje:"); peopleSet.load("data\\ban.txt"); Ks.ounn(peopleSet.toVisualizedString("")); Ks.oun("Išsiaiškinkite, kodėl medis augo tik į vieną pusę."); Ks.oun(""); Ks.oun("Žmonių aibė AVL-medyje:"); peopleSetAVL.load("data\\ban.txt"); Ks.ounn(peopleSetAVL.toVisualizedString("")); Set<String> peopleSet4 = Zmones.duplicatePersonNames(peopleArray); Ks.oun("Pasikartojantys žmonės:\n" + peopleSet4.toString()); Set<String> peopleSet5 = Zmones.uniquePersonSurnames(peopleArray); Ks.oun("Unikalūs žmonės :\n" + peopleSet5.toString()); } static ParsableSortedSet generateSet(int kiekis, int generN) { people = new Person[generN]; for (int i = 0; i < generN; i++) { people[i] = new Person.Builder().buildRandom(); } Collections.shuffle(Arrays.asList(people)); cSeries.clear(); Arrays.stream(people).limit(kiekis).forEach(cSeries::add); return cSeries; } }
afb2f8864fd3cd642fdca074520a7c8196118bf0
d3cfe92261863f6f2dc764cc0b7e0983ef7ed1f2
/src/SIS/entidad/RespuestaDatoFastPJ.java
3a7472b937e4f2a2a7e6684380d4e8daebf11c5f
[]
no_license
edisonpaul/datoStupendo
41dde06ac45b0f7b12867431c8957711bd84b935
4cac513fb4c2b3a72273b3bd565c8ba99cf8eddc
refs/heads/master
2023-05-05T10:34:38.989440
2021-05-28T00:21:46
2021-05-28T00:21:46
371,534,404
0
0
null
null
null
null
UTF-8
Java
false
false
1,004
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package SIS.entidad; /** * * @author contabilidad04 */ public class RespuestaDatoFastPJ { private boolean result; private Empresa datos; private String error; public String getError() { return error; } public void setError(String error) { this.error = error; } public boolean isResult() { return result; } public void setResult(boolean result) { this.result = result; } public Empresa getDatos() { return datos; } public void setDatos(Empresa datos) { this.datos = datos; } @Override public String toString() { return "RespuestaDatoFastPJ{" + "result=" + result + ", datos=" + datos + ", error=" + error + '}'; } }
200a000402869acd13dee2a6d55d29010320125c
209e0067549257035c6258496c1cea01281fb037
/src/com/evan/javaaaaaaaaa/jvm/why/box/BoxDemo.java
122f466a7335c9c4703530aa0b64cc2a7fbbf4ab
[ "Apache-2.0" ]
permissive
tianshangstar/Javaaaaaaaaa
8e1844b0b33ebc57b0158f429e7517d20c441dd7
423457a6f056e6443627d8ffeff79a74d3a59fce
refs/heads/master
2022-09-25T14:56:57.188867
2022-09-05T08:11:59
2022-09-05T08:11:59
144,517,281
2
0
Apache-2.0
2022-06-17T03:22:09
2018-08-13T02:01:51
Java
UTF-8
Java
false
false
944
java
package com.evan.javaaaaaaaaa.jvm.why.box; public class BoxDemo { public static void main(String[] args) { Integer a = 1; Integer b = 2; Integer c = 3; Integer d = 3; Integer e = 128; Integer f = 128; Long g = 3L, h=3L, i = 128L, j = 128L; System.out.println(c == d); // true ?????? IntegerCache -128~127,进行的是原生数据类型的比较 System.out.println(e == f); // false ?????? 不是从IntegerCache中取,so.. System.out.println(c == (a + b)); // true ==运算符在遇到算数运算会自动拆箱 System.out.println(c.equals(a + b)); // true a + b自动封箱 System.out.println(g == (a + b)); // true ==运算符在遇到算数运算会自动拆箱 System.out.println(g.equals(a + b)); // 一直是false,因为g是long a+b不是long System.out.println(g == h); System.out.println(i == j); } }
6ba1b2e201a5d49367dfdb5e3e1a8e0355dbe3d4
751fee6da65e0a0b8c37dcb405f32569be7f224a
/src/com/wallpaperoftheweek/servlet/Image.java
95c452b09d95114a52b45265256ab9731359cde0
[]
no_license
nancyd/wallpaperOfTheWeek
cfdd336d4dbd7a5fdf92b63775280d6e0981d7b3
c124805a25186c153cf4d840c71ac4decf557550
refs/heads/master
2021-01-10T21:33:01.053949
2011-01-24T17:20:55
2011-01-24T17:20:55
1,282,757
0
0
null
null
null
null
UTF-8
Java
false
false
2,941
java
package com.wallpaperoftheweek.servlet; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.servlet.http.*; import com.google.appengine.api.blobstore.BlobKey; import com.google.appengine.api.blobstore.BlobstoreService; import com.google.appengine.api.blobstore.BlobstoreServiceFactory; import com.googlecode.objectify.Key; import com.googlecode.objectify.NotFoundException; import com.wallpaperoftheweek.DAO; import com.wallpaperoftheweek.model.ScaledDown; import com.wallpaperoftheweek.model.Wallpaper; @SuppressWarnings("serial") public class Image extends HttpServlet { private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); private static Pattern imagePattern = Pattern.compile("^/image/(\\d+).jpg$"); private static Pattern previewPattern = Pattern.compile("^/image/(\\d+)_preview.jpg$"); private static Pattern thumbnailPattern = Pattern.compile("^/image/(\\d+)_thumbnail.jpg$"); private static Pattern weekPreviewPattern = Pattern.compile("^/image/weekwallpaper/(\\d{8})_preview\\.jpg$"); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String requestURI = req.getRequestURI(); DAO dao = new DAO(); // Serve image try { Matcher m = imagePattern.matcher(requestURI); if (m.find()) { long id = Long.parseLong(m.group(1)); Wallpaper wallpaper = dao.ofy().get(new Key<Wallpaper>(Wallpaper.class, id)); blobstoreService.serve(wallpaper.blobKey, resp); return; } } catch (NotFoundException e) { // Empty catch. Error reported bellow } // Serve preview image { Matcher m = previewPattern.matcher(requestURI); if (m.find()) { long id = Long.parseLong(m.group(1)); ScaledDown scaledDown = dao.ofy().query(ScaledDown.class) .filter("size =", ScaledDown.Size.SIZE_PREVIEW) .filter("wallpaperId =", id) .get(); if (scaledDown != null) { resp.setContentType("image/jpeg"); resp.getOutputStream().write(scaledDown.data); return; } } } // Serve thumbnail { Matcher m = thumbnailPattern.matcher(requestURI); if (m.find()) { long id = Long.parseLong(m.group(1)); ScaledDown scaledDown = dao.ofy().query(ScaledDown.class) .filter("size =", ScaledDown.Size.SIZE_THUMB) .filter("wallpaperId =", id) .get(); if (scaledDown != null) { resp.setContentType("image/jpeg"); resp.getOutputStream().write(scaledDown.data); return; } } } { Matcher m = weekPreviewPattern.matcher(requestURI); if (m.find()) { BlobKey blobKey = new BlobKey(m.group(1)); blobstoreService.serve(blobKey, resp); return; } } resp.setStatus(404); resp.setContentType("text/plain"); resp.getWriter().println("Image not found."); } }
249ca1f3bfaca2d3209712646373b0f712c6c086
c569d831039e12a0adaa444db2e3e9c42cb516c6
/bkallenway/sourcecode/visitor/src/main/java/com/allenway/visitor/service/ArticleService.java
3cb0ceb3ac359fc8ca364805c7324d23a3b3a93f
[]
no_license
rucky2013/Allen6314
0237aa9a67e4355af731ea9866b396967867dddb
3224b788cab1a4403b1167638893f643438eaf02
refs/heads/master
2021-01-21T08:46:15.414388
2016-05-05T03:03:00
2016-05-05T03:03:00
58,107,004
1
0
null
2016-05-05T05:37:43
2016-05-05T05:37:43
null
UTF-8
Java
false
false
466
java
package com.allenway.visitor.service; import com.allenway.visitor.entity.Article; import java.util.List; /** * Created by wuhuachuan on 16/3/9. */ public interface ArticleService { Article save(Article article); Article findArticleById(String id); void delete(Article article); List<Article> findArticlesByClassifyId(String id); List<Article> findAllArticles(); //找到推荐的文章 List<Article> findRecommendArticles(); }
69c6fd4ad1f52ba06455520df04a91a9059dca4a
c86597c2f799019531d2f4eaab585ece627bdeb8
/original/workspace/Demo17/gen/com/tarena/demo17/BuildConfig.java
e5f29d828597b475838f3970632978c28c881a99
[]
no_license
kongxiangyue/micro_android_base
bf0fd2f6b5a100ae9c1c53036e7ad59b89161c41
405746fdb4c8fafefb1ac260c7df83eeecac0b1f
refs/heads/master
2021-04-27T16:13:34.791069
2018-08-13T03:20:04
2018-08-13T03:20:04
122,483,498
0
0
null
null
null
null
UTF-8
Java
false
false
259
java
/*___Generated_by_IDEA___*/ package com.tarena.demo17; /* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ public final class BuildConfig { public final static boolean DEBUG = Boolean.parseBoolean(null); }
4d1789a508e480561ed4cb12f0e30b6db74dcc20
bfd0edcb2c35e9da4156c1d7b0eb45674a7ddf3c
/Java Basic Exercises -117 exercises with solution/Bai5.java
b45c409c6393a8bec70e91ccb358a76d74518216
[]
no_license
PhungThiHuyenTrang/CORE-JAVA
8cb2cd4c19632bba1c6ee4368ff229b105ecf7d3
1a04def2469fe1ec77a539369feb21af7264e0e9
refs/heads/master
2021-04-09T15:36:41.822166
2018-04-13T15:24:34
2018-04-13T15:24:34
125,636,083
0
0
null
null
null
null
UTF-8
Java
false
false
153,089
java
<!DOCTYPE html> <!-- saved from url=(0065)https://www.w3resource.com/java-exercises/basic/index.php#editorr --> <html xmlns:fb="facebook.com/2008/fbml" class="mdl-js"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script async="" data-rocketsrc="//cse.google.com/adsense/search/async-ads.js" data-rocketoptimized="true"></script><script type="text/javascript"> (function() { window.trackingUtils=function(k,b,d,n,o,g,c,p,r,m){var f={},i=new RegExp("/(ref=[\\w]+)/?","i"),h=function(s){return s&&encodeURIComponent(s).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");},l=(function(){var s=document.createElement("a");s.href=(window.location!==window.parent.location)?document.referrer:document.location;return s.protocol+"//"+s.hostname+((s.port===""||s.port==="80"||s.port==="443")?"":(":"+s.port))+(s.pathname.indexOf("/")!==0?("/"+s.pathname):s.pathname);}()),q=(function(){return h(l);}()),j=function(s,u,v,t){if(typeof v==="string"&&v!==""){if(s.search===""){s.search="?"+u+"="+v;}else{if(!s.search.match(new RegExp("[?&]"+u+"="))){s.search=s.search.replace(/\?/,"?"+u+"="+v+"&");}else{if(t){s.search=s.search.replace(new RegExp(u+"=([^&]*)"),u+"="+v);}}}}return s;},e=function(u,s,t){if(typeof t==="string"&&t!==""){if(!u.match(/\?/)){u=u+"?"+s+"="+t;}else{if(!u.match(s)){u=u.replace(/\?/,"?"+s+"="+t+"&");}}}return u;},a=function(t){var s=(typeof c!=="undefined")?c:0;if(typeof t!=="undefined"){s=t;}return s;};f.addRefUrls=function(x,y,t,s){var z=new RegExp("^http://.*(amazon|endless|myhabit|amazonwireless|javari|smallparts)\\.(com|ca|co\\.jp|de|fr|co\\.uk|cn|it|es)/.*","i"),u,w,v;for(v=0;v<x.length;v++){x[v].rel="nofollow";u=String(x[v].href);if(w=u.match(z)){x[v].href=f.addTrackingParameters(x[v],y,t,s);}}};f.addRefRefUrl=function(s){return j(s,"ref-refURL",q);};f.getRefRefUrl=function(){return q;};f.getRawRefUrl=function(){return l;};f.addSignature=function(t,s,u){return j(j(t,"sig",s),"sigts",u);};f.addLinkCode=function(t,s){return j(t,"linkCode",s);};f.addTrackingId=function(t,s){return j(t,"tag",s);};f.addLinkId=function(s,t){return j(s,"linkId",t);};f.addSubtag=function(s,t){return j(s,"ascsubtag",t);};f.addCreativeAsin=function(s,t){return j(j(s,"creativeASIN",t),"adId",t);};f.addAdType=function(t,s){return j(t,"adType",s);};f.addAdMode=function(s,t){return j(s,"adMode",t);};f.addAdFormat=function(t,s){return j(t,"adFormat",s);};f.addImpressionTimestamp=function(s,t){if(typeof t==="number"){t=t.toString();}return j(s,"impressionTimestamp",t);};f.convertToRedirectedUrl=function(s,v,t){var u=document.createElement("a");u.setAttribute("href",v);if(typeof t!=="undefined"){j(u,t,h(s.getAttribute("href")),true);}else{u.setAttribute("href",v+"/"+u.getAttribute("href"));}s.setAttribute("href",u.getAttribute("href"));return s;};f.getImpressionToken=function(){return g;};f.getClickUrl=function(){return o;};f.addImpressionToken=function(t,u){var s=a(u);if(typeof g==="string"&&g!==""){j(t,"imprToken",g);if(typeof s!=="undefined"){j(t,"slotNum",s);}}return t;};f.addImpressionTokenStr=function(u,t){var s=a(t);if(typeof g==="string"&&g!==""){u=e(u,"imprToken",g);if(typeof s!=="undefined"){u=e(u,"slotNum",s);}}return u;};f.addTrackingParameters=function(y,z,x,C,v,s,w,u,t,D,B,A){return f.addSignature(f.addCreativeAsin(f.addLinkId(f.addTrackingId(f.addSubtag(f.addLinkCode(f.addRefRefUrl(f.addImpressionToken(f.addRefMarker(f.addAdType(f.addAdMode(f.addAdFormat(f.addImpressionTimestamp(y,A),B),D),t),v))),x),p),C),z),s),w,u);};f.addRefMarker=function(t,v){var u,s=false;if(typeof v==="undefined"){return t;}if(u=t.pathname.match(i)){t.pathname=t.pathname.replace(u[1],"ref="+v);}else{s=(t.pathname.charAt(t.pathname.length-1)==="/");t.pathname=t.pathname+(s?"":"/")+"ref="+v;}return t;};f.getRefMarker=function(s){var t;if(t=s.pathname.match(i)){return t[1].substr(4);}else{return undefined;}};f.makeForesterCall=function(u){var s=undefined,t;u.refUrl=document.location.href;if(typeof JSON!=="undefined"){t=JSON.stringify(u);}else{if(typeof amzn_assoc_utils!=="undefined"&&typeof amzn_assoc_utils.stringify==="function"){t=amzn_assoc_utils.stringify(u);}else{return;}}if(typeof n==="string"){s=n+"?assoc_payload="+encodeURIComponent(t);}if(typeof s!=="undefined"){(new Image()).src=s;}};f.recordImpression=function(t,s,v,u){v.linkCode=t;v.trackingId=s;if(m||!r){f.makeForesterCall(v);}else{f.addABPFlag(v,f.makeForesterCall);}if(typeof u==="undefined"||!u){(new Image()).src=d+"?l="+t+"&t="+s+"&o="+k+"&cb="+(new Date()).getTime();}};f.addAAXClickUrls=function(t){var v,u,s;if(typeof t==="undefined"||typeof o==="undefined"){return;}for(u=0;u<t.length;u++){s=String(t[u].href);if(s.indexOf(o)<0){v=o+s;t[u].href=v;}}};f.addAAXClickUrl=function(s){if(typeof s==="undefined"||typeof s==="undefined"||s.indexOf(o)===0){return s;}return o+s;};f.updateLinks=function(t,v){var u,s;if(typeof v!=="function"){return;}for(u=0;u<t.length;u++){s=String(t[u].href);t[u].href=v(s);}};f.elementInViewPort=function(s){var t=s.getBoundingClientRect(),u=(t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth));return{posX:t.left+window.pageXOffset,posY:t.top+window.pageYOffset,inViewPort:u};};f.initialViewabilityCall=function(y,t,v,x){var s=undefined,u,w={adViewability:[{above_the_fold:y,topPos:t,leftPos:v,slotNum:x}]};if(typeof JSON!=="undefined"){u=JSON.stringify(w);}else{if(typeof amzn_assoc_utils!=="undefined"&&typeof amzn_assoc_utils.stringify==="function"){u=amzn_assoc_utils.stringify(w);}else{u="";}}if(typeof n==="string"){s=n+u;}if(typeof s!=="undefined"){(new Image()).src=s+"&cb="+(new Date()).getTime();}};f.makeViewabilityCall=function(v){var s=undefined,t,u={adViewability:[{viewable:true,slotNum:v}]};if(typeof JSON!=="undefined"){t=JSON.stringify(u);}else{if(typeof amzn_assoc_utils!=="undefined"&&typeof amzn_assoc_utils.stringify==="function"){t=amzn_assoc_utils.stringify(u);}else{t="";}}if(typeof n==="string"){s=n+t;}if(typeof s!=="undefined"){(new Image()).src=s+"&cb="+(new Date()).getTime();}};f.addABPFlag=function(v,D){var x=false,w=2,u=document.body?document.body.appendChild(new Image()):new Image(),t=document.body?document.body.appendChild(new Image()):new Image(),A=false,y=false,s=Math.random()*11,C=r+"?ch=*&rn=*",B=function(F,E){if(w===0||E>1000){v.supplySideMetadata={ABPInstalled:w===0&&x};F(v);}else{setTimeout(function(){B(F,E*2);},E*2);}},z=function(){if(--w){return;}x=!A&&y;};u.style.display="none";t.style.display="none";u.onload=z;u.onerror=function(){A=true;z();};u.src=C.replace(/\*/,1).replace(/\*/,s);t.onload=z;t.onerror=function(){y=true;z();};t.src=C.replace(/\*/,2).replace(/\*/,s);B(D,250);};return f;};window.elemTracker=function(b){var a={};a.trackElements=function(d,c){var f,e;if(typeof d!=="undefined"&&d.length>0&&typeof c==="function"){window.addEventListener("scroll",function(){for(f=0;f<d.length;f++){e=b.elementInViewPort(d[f]);if(e.inViewPort){c();}}},false);}};return a;}; var amznAutoTaggerMaker=function(j,l,m){var I={CA:"ca",CN:"cn",IN:"in",DE:"de",FR:"fr",GB:"co.uk",JP:"co.jp",US:"com"},F={CA:[],CN:[],IN:[],DE:["javari"],FR:["javari"],GB:["javari"],JP:["javari"],US:["smallparts","amazonwireless","endless","myhabit"]},x=(function(){var L=-1,K={};K.getNextSlotNum=function(){return ++L;};return K;}()),d,B,J=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight),g=Math.max(document.body.scrollWidth,document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.scrollWidth,document.documentElement.offsetWidth),w={totalDocWidth:g,totalDocHeight:J,logType:"onetag_pageload",pageTitle:document.title},C="w50",q="w61",o="g12",k={},s=new RegExp("%3F"),t=[],H=new Object(),D=false,E="",c="",r=0,b=0,A=0,v=new RegExp("amzn.to"),e=new RegExp(j.redirectorEndPoint),p=["kdp.amazon.com"],n=function(L){var M,K=false;for(M=0;M<p.length;M++){if(L.match(p[M])){K=true;break;}}return K;},y=function(K){return K.nextSibling&&K.nextSibling.tagName==="IMG"&&K.nextSibling.hasAttribute("src")&&(K.nextSibling.getAttribute("src").search(/ir-[a-z]{2}\.amazon-adsystem\.com/)>-1||K.nextSibling.getAttribute("src").search(/www\.assoc-amazon\.*/)>-1);},f=function(K){if(!K.href.match(e)){K.href=j.redirectorEndPoint+K.href;}},z=function(U,Z){var V=new RegExp("/(ref=[\\w]+)/?","i"),Q,Y=false,L,O,P=false,T=U.search.match(/\?tag=([^&]+)|&tag=([^&]+)|\?tag-value=([^&]+)|&tag-value=([^&]+)|\?tag_value=([^&]+)|&tag_value=([^&]+)|\?t=([^&]+)|&t=([^&]+)/),N=U.search.match(/\?tag=|&tag=|\?tag-value=|&tag-value=|\?tag_value=|&tag_value=|\?t=|&t=/),K=U.search.match(/(linkCode|link_code|lc)=([^&]+)/i),S=l.elementInViewPort(U),X={autoTagged:false,overwritten:false,geoRedirected:false,atf:S.inViewPort},M=x.getNextSlotNum(),R={destinationURL:U.href,slotNum:M,atfInFirstLoad:S.inViewPort,posX:S.posX,posY:S.posY,logType:"onetag_textlink"},W=y(U);X.slotNum=M;if(U.pathname.charAt(U.pathname.length-1)!=="/"){U.pathname=U.pathname+"/";}if(U.search===""){U.search="?imprToken="+l.getImpressionToken()+"&slotNum="+M;}else{U.search=U.search.replace(/\?/,"?imprToken="+l.getImpressionToken()+"&slotNum="+M+"&");}if(j.enableAutoTagging){X.autoTagged=true;if(T){if(j.overwrite){for(O=1;O<9;O++){if(T[O]!=undefined){U.search=U.search.replace(T[O],Z);break;}}X.overwritten=true;Y=true;}}else{if(N){U.search=U.search.replace(/tag=/,"tag="+Z);Y=true;}else{U.search=U.search.replace(/\?/,"?tag="+Z+"&");Y=true;}}}if(K&&typeof j.overridableLinkCodes[K[2]]!=="undefined"){P=true;}if(K&&!P){L=K[2];}else{L=Y?C:q;}if(K){R.oldLinkCode=K[2];U.search=U.search.replace(K[2],L);}else{U.search=U.search.replace(/\?/,"?linkCode="+L+"&");}if(Q=U.pathname.match(V)){U.pathname=U.pathname.replace(Q[1],"ref=as_at");}else{U.pathname=U.pathname+"ref=as_at";}if(Y){l.recordImpression(L,Z,R,W);}else{if(typeof T!=="undefined"&&T instanceof Array&&T.length>=O+1&&typeof T[O]==="string"){l.recordImpression(L,T[O],R,W);}else{l.recordImpression(L,"",R,W);}}if(k.shouldBeGeoRedirected()){X.geoRedirected=true;f(U);}if(U.hasAttribute("data-amzn-asin")&&!U.search.match("creativeASIN")){U.search=U.search.replace(/\?/,"?creativeASIN="+U.getAttribute("data-amzn-asin")+"&");}l.initialViewabilityCall(S.inViewPort,S.posX,S.posY,M);U.href=l.addAAXClickUrl(U.href);return X;},G=function(K){if(K.href.match(s)){B=K.href.split(s);K.href=B[0]+"?"+decodeURIComponent(B[1]);}},a=function(P,L,K,O){var N,M;for(N=0;N<L.length;N++){for(M=0;M<K.length;M++){if(window.addEventListener){L[N].addEventListener(K[M],O,false);}else{L[N].attachEvent("on"+K[M],O);}P.push({el:L[N],h:O,t:K[M]});}}},h=function(){var K="";for(i=0;i<j.itemRefs.length;i++){if(typeof j.itemRefs[i].type!=="undefined"&&j.itemRefs[i].type==="ASIN"&&typeof j.itemRefs[i].sourceLink!=="undefined"&&String(j.itemRefs[i].sourceLink).match(v)!==null&&typeof j.itemRefs[i].destinationLink!=="undefined"){H[j.itemRefs[i].sourceLink]=j.itemRefs[i].destinationLink;if(E!==""){K=",";}E=E+K+j.itemRefs[i].sourceLink;r++;}}},u=function(L,K){m.trackElements([L],function(){if(typeof K!==undefined&&K.slotNum!==undefined&&(K.viewed===undefined||!K.viewed)){l.makeViewabilityCall(K.slotNum);K.viewed=true;}});};if(j.locale!=undefined){d=j.locale;}else{d="US";}k.shouldBeGeoRedirected=function(){return j.enableGeoRedirection&&(j.region!==""&&j.region!==j.viewerCountry);};k.publisherCallBack=function(){window["amzn_assoc_client_cb_"+j.adUnitSlotNum]({type:"onload",data:{},widget:k});};k.decorateLinkElement=function(K){G(K);linkProperties=z(K,j.trackingId);u(K,linkProperties);return linkProperties;};k.tagLinks=function(ab){var ad,ac,L,W,af,Y=[],ah=0,T,V,ae,aa,ag,K,U,R=0,N=0,X=0,M=0,Q=0,O=0,P,S,Z="";L=I[d];W=F[d];af=new RegExp("^(http|https)://(www|[\\w\\-\\.]+)?amazon\\.("+L+")/","i");if(W){for(ah=0;ah<W.length;ah++){T=L;if(L=="co.jp"){T="co.jp|jp";}Y[ah]=new RegExp("^(http|https)://(www\\.)?("+W[ah]+")\\.("+T+")/","i");}}V=ab.getElementsByTagName("a");if(!D){h();D=true;}for(ad=0;ad<V.length;ad++){U=undefined;ae=String(V[ad].href);if(aa=ae.match(af)&&!n(ae)){U=k.decorateLinkElement(V[ad]);}else{if(j.isShortLinksSupported&&(ag=ae.match(v))!==null){b++;if(c!==""){Z=",";}c=c+Z+V[ad].href;P=H[V[ad].href];if(typeof P!=="undefined"){A++;V[ad].setAttribute("href",P);U=k.decorateLinkElement(V[ad]);}else{if(k.shouldBeGeoRedirected()){U=k.decorateLinkElement(V[ad]);}}}else{for(K=0;K<Y.length;K++){if(aa=ae.match(Y[K])){k.decorateLinkElement(V[ad]);}}}}if(typeof U!=="undefined"){if(U.autoTagged){N++;}if(U.overwritten){O++;}if(U.geoRedirected){X++;}if(U.atf){M++;}else{Q++;}R++;}}w.numLinks=R;w.numAutoTaggedLinks=N;w.autoTaggingEnabled=j.enableAutoTagging;w.geoRedirectEnabled=j.enableGeoRedirection;w.numLinksATF=M;w.numLinksBTF=Q;w.shortLinksInLivePool=E;w.shortLinksInPage=c;w.shortLinksInLivePoolCount=r;w.shortLinksInPageCount=b;w.shortLinksMatchCount=A;l.recordImpression(j.linkCode,j.trackingId,w);};return k;}; var spec = { trackingId : "w3resource-20", region : "US", overwrite : false, enableAutoTagging : false, linkCode : "w49", overridableLinkCodes : { "am1": "" , "am2": "" , "am3": "" , "as1": "" , "as2": "" , "as3": "" , "as4": "" , "li1": "" , "li2": "" , "li3": "" , "ll1": "" , "ll2": "" }, enableGeoRedirection : true, redirectorEndPoint : "https://assoc-redirect.amazon.com/g/r/", adUnitSlotNum : "0", itemRefs : [], isShortLinksSupported : true, viewerCountry : "VN" }, trackingUtils = window.trackingUtils( "1", "//fls-na.amazon-adsystem.com/1/associates-ads/1/OP/r/json", "//ir-na.amazon-adsystem.com/e/ir", "https://aax-us-east.amazon-adsystem.com/x/px/QnAWKRX62gxFhydqVWd0sI0AAAFiALITZQEAAAFKAQyHLtw/", "https://aax-us-east.amazon-adsystem.com/x/c/QnAWKRX62gxFhydqVWd0sI0AAAFiALITZQEAAAFKAQyHLtw/", "c7m2UpyhdJ2brVYuWb8aTw", undefined, undefined, undefined, true ); window.amznAutoTagger = amznAutoTaggerMaker(spec, trackingUtils, window.elemTracker(trackingUtils)); window.amznAutoTagger.tagLinks(document); window.amznAutoTagger.publisherCallBack(); }()); //# sourceURL=dynscript-0.js</script> <script src="./Bai5_files/ca-pub-2153208817642134.js.tải xuống"></script><script type="text/javascript" async="" src="./Bai5_files/cse.js.tải xuống"></script><script async="" src="./Bai5_files/analytics.js.tải xuống"></script><script type="text/javascript"> //<![CDATA[ window.__cfRocketOptions = {byc:0,p:0,petok:"040628e31330be92843c497cc8f3f0fa4c78edd2-1520430081-1800"}; //]]> </script> <script type="text/javascript" src="./Bai5_files/rocket.min.js.tải xuống"></script> <link type="text/css" rel="stylesheet" href="./Bai5_files/material.min.css"> <link type="text/css" rel="stylesheet" href="./Bai5_files/additional.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="https://www.w3resource.com/images/favicon.png"> <title>Java Basic Programming Exercises - w3resource</title> <meta name="Keywords" content="w3resource, Java programming exercises, exercises, solution"> <meta name="Description" content="Practice with solution of exercises on Java basic: examples on variables, date, operator, input, output and more from w3resource."> <meta property="og:title" content="Java Basic Programming Exercises - w3resource"> <meta property="og:description" content="Practice with solution of exercises on Java basic: examples on variables, date, operator, input, output and more from w3resource."> <meta property="og:url" content="https://www.w3resource.com/java-exercises/basic/index.php"> <meta property="og:image" content="//www.w3resource.com/w3r_images/java-exercises.png"> <meta property="og:site_name" content="w3resource"> <link rel="preload" href="./Bai5_files/integrator.js.tải xuống" as="script"><script type="text/javascript" src="./Bai5_files/integrator.js.tải xuống"></script><link rel="preload" href="./Bai5_files/integrator.js(1).tải xuống" as="script"><script type="text/javascript" src="./Bai5_files/integrator.js(1).tải xuống"></script><script src="./Bai5_files/jsapi" type="text/javascript"></script><link type="text/css" href="./Bai5_files/default+en.css" rel="stylesheet"><link type="text/css" href="./Bai5_files/default.css" rel="stylesheet"><script type="text/javascript" src="./Bai5_files/default+en.I.js.tải xuống"></script><style type="text/css">.gsc-control-cse{font-family:Arial, sans-serif;border-color:#FFFFFF;background-color:#FFFFFF}.gsc-control-cse .gsc-table-result{font-family:Arial, sans-serif}input.gsc-input,.gsc-input-box,.gsc-input-box-hover,.gsc-input-box-focus{border-color:#D9D9D9}.gsc-search-button-v2,.gsc-search-button-v2:hover,.gsc-search-button-v2:focus{border-color:#666666;background-color:#CECECE;background-image:none;filter:none}.gsc-search-button-v2 svg{fill:#FFFFFF}.gsc-tabHeader.gsc-tabhInactive{border-color:#E9E9E9;background-color:#E9E9E9}.gsc-tabHeader.gsc-tabhActive{border-color:#FF9900;border-bottom-color:#FFFFFF;background-color:#FFFFFF}.gsc-tabsArea{border-color:#FF9900}.gsc-webResult.gsc-result,.gsc-results .gsc-imageResult{border-color:#FFFFFF;background-color:#FFFFFF}.gsc-webResult.gsc-result:hover,.gsc-imageResult:hover{border-color:#FFFFFF;background-color:#FFFFFF}.gs-webResult.gs-result a.gs-title:link,.gs-webResult.gs-result a.gs-title:link b,.gs-imageResult a.gs-title:link,.gs-imageResult a.gs-title:link b{color:#0000CC}.gs-webResult.gs-result a.gs-title:visited,.gs-webResult.gs-result a.gs-title:visited b,.gs-imageResult a.gs-title:visited,.gs-imageResult a.gs-title:visited b{color:#0000CC}.gs-webResult.gs-result a.gs-title:hover,.gs-webResult.gs-result a.gs-title:hover b,.gs-imageResult a.gs-title:hover,.gs-imageResult a.gs-title:hover b{color:#0000CC}.gs-webResult.gs-result a.gs-title:active,.gs-webResult.gs-result a.gs-title:active b,.gs-imageResult a.gs-title:active,.gs-imageResult a.gs-title:active b{color:#0000CC}.gsc-cursor-page{color:#0000CC}a.gsc-trailing-more-results:link{color:#0000CC}.gs-webResult .gs-snippet,.gs-imageResult .gs-snippet,.gs-fileFormatType{color:#000000}.gs-webResult div.gs-visibleUrl,.gs-imageResult div.gs-visibleUrl{color:#008000}.gs-webResult div.gs-visibleUrl-short{color:#008000}.gs-webResult div.gs-visibleUrl-short{display:none}.gs-webResult div.gs-visibleUrl-long{display:block}.gs-promotion div.gs-visibleUrl-short{display:none}.gs-promotion div.gs-visibleUrl-long{display:block}.gsc-cursor-box{border-color:#FFFFFF}.gsc-results .gsc-cursor-box .gsc-cursor-page{border-color:#E9E9E9;background-color:#FFFFFF;color:#0000CC}.gsc-results .gsc-cursor-box .gsc-cursor-current-page{border-color:#FF9900;background-color:#FFFFFF;color:#0000CC}.gsc-webResult.gsc-result.gsc-promotion{border-color:#336699;background-color:#FFFFFF}.gsc-completion-title{color:#0000CC}.gsc-completion-snippet{color:#000000}.gs-promotion a.gs-title:link,.gs-promotion a.gs-title:link *,.gs-promotion .gs-snippet a:link{color:#0000CC}.gs-promotion a.gs-title:visited,.gs-promotion a.gs-title:visited *,.gs-promotion .gs-snippet a:visited{color:#0000CC}.gs-promotion a.gs-title:hover,.gs-promotion a.gs-title:hover *,.gs-promotion .gs-snippet a:hover{color:#0000CC}.gs-promotion a.gs-title:active,.gs-promotion a.gs-title:active *,.gs-promotion .gs-snippet a:active{color:#0000CC}.gs-promotion .gs-snippet,.gs-promotion .gs-title .gs-promotion-title-right,.gs-promotion .gs-title .gs-promotion-title-right *{color:#000000}.gs-promotion .gs-visibleUrl,.gs-promotion .gs-visibleUrl-short{color:#008000}</style><script type="text/javascript" async="" src="./Bai5_files/embed.js.tải xuống"></script><link rel="preload" as="style" href="https://c.disquscdn.com/next/embed/styles/lounge.2d848eddee1b8c12749b72a04b2b33dc.css"><link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/common.bundle.774abcf1e2c32f6ee53499b090f48ff0.js"><link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/lounge.bundle.8241ae5fc761eb94635acdc63f5fd29f.js"><link rel="preload" as="script" href="https://disqus.com/next/config.js"><script src="./Bai5_files/clipboard.min.js.tải xuống"></script><style>#aswift_1_anchor{opacity:1 !important;overflow: visible !important}#_no-clickjacking-0{opacity:1 !important;overflow: visible !important}</style><style>#_no-clickjacking-1{opacity:1 !important;overflow: visible !important}</style><style>#_no-clickjacking-2{opacity:1 !important;overflow: visible !important}#_no-clickjacking-3{opacity:1 !important;overflow: visible !important}#_no-clickjacking-4{opacity:1 !important;overflow: visible !important}#_no-clickjacking-5{opacity:1 !important;overflow: visible !important}#_no-clickjacking-6{opacity:1 !important;overflow: visible !important}#_no-clickjacking-7{opacity:1 !important;overflow: visible !important}</style><style>#_no-clickjacking-8{opacity:1 !important;overflow: visible !important}</style><style>#_no-clickjacking-9{opacity:1 !important;overflow: visible !important}</style><style></style><style type="text/css">.gscb_a{display:inline-block;font:27px/13px arial,sans-serif}.gsst_a .gscb_a{color:#a1b9ed;cursor:pointer}.gsst_a:hover .gscb_a,.gsst_a:focus .gscb_a{color:#36c}.gsst_a{display:inline-block}.gsst_a{cursor:pointer;padding:0 4px}.gsst_a:hover{text-decoration:none!important}.gsst_b{font-size:16px;padding:0 2px;position:relative;user-select:none;-webkit-user-select:none;white-space:nowrap}.gsst_e{opacity:0.55;}.gsst_a:hover .gsst_e,.gsst_a:focus .gsst_e{opacity:0.72;}.gsst_a:active .gsst_e{opacity:1;}.gsst_f{background:white;text-align:left}.gsst_g{background-color:white;border:1px solid #ccc;border-top-color:#d9d9d9;box-shadow:0 2px 4px rgba(0,0,0,0.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,0.2);margin:-1px -3px;padding:0 6px}.gsst_h{background-color:white;height:1px;margin-bottom:-1px;position:relative;top:-1px}.gsib_a{width:100%;padding:4px 6px 0}.gsib_a,.gsib_b{vertical-align:top}.gssb_c{border:0;position:absolute;z-index:989}.gssb_e{border:1px solid #ccc;border-top-color:#d9d9d9;box-shadow:0 2px 4px rgba(0,0,0,0.2);-webkit-box-shadow:0 2px 4px rgba(0,0,0,0.2);cursor:default}.gssb_f{visibility:hidden;white-space:nowrap}.gssb_k{border:0;display:block;position:absolute;top:0;z-index:988}.gsdd_a{border:none!important}.gsq_a{padding:0}.gsq_a{padding:0}.gscsep_a{display:none}.gssb_a{padding:0 7px}.gssb_a,.gssb_a td{white-space:nowrap;overflow:hidden;line-height:22px}#gssb_b{font-size:11px;color:#36c;text-decoration:none}#gssb_b:hover{font-size:11px;color:#36c;text-decoration:underline}.gssb_g{text-align:center;padding:8px 0 7px;position:relative}.gssb_h{font-size:15px;height:28px;margin:0.2em;-webkit-appearance:button}.gssb_i{background:#eee}.gss_ifl{visibility:hidden;padding-left:5px}.gssb_i .gss_ifl{visibility:visible}a.gssb_j{font-size:13px;color:#36c;text-decoration:none;line-height:100%}a.gssb_j:hover{text-decoration:underline}.gssb_l{height:1px;background-color:#e5e5e5}.gssb_m{color:#000;background:#fff}.gsfe_a{border:1px solid #b9b9b9;border-top-color:#a0a0a0;box-shadow:inset 0px 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0px 1px 2px rgba(0,0,0,0.1);-webkit-box-shadow:inset 0px 1px 2px rgba(0,0,0,0.1);}.gsfe_b{border:1px solid #4d90fe;outline:none;box-shadow:inset 0px 1px 2px rgba(0,0,0,0.3);-moz-box-shadow:inset 0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:inset 0px 1px 2px rgba(0,0,0,0.3);}.gssb_a{padding:0 9px}.gsib_a{padding-right:8px;padding-left:8px}.gsst_a{padding-top:5.5px}.gssb_e{border:0}.gssb_l{margin:5px 0}input.gsc-input::-webkit-input-placeholder{font-size:14px}input.gsc-input:-moz-placeholder{font-size:14px}input.gsc-input::-moz-placeholder{font-size:14px}input.gsc-input:-ms-input-placeholder{font-size:14px}input.gsc-input:focus::-webkit-input-placeholder{color:transparent}input.gsc-input:focus:-moz-placeholder{color:transparent}input.gsc-input:focus::-moz-placeholder{color:transparent}input.gsc-input:focus:-ms-input-placeholder{color:transparent}.gssb_c .gsc-completion-container{position:static}.gssb_c{z-index:5000}.gsc-completion-container table{background:transparent;font-size:inherit;font-family:inherit}.gssb_c > tbody > tr,.gssb_c > tbody > tr > td,.gssb_d,.gssb_d > tbody > tr,.gssb_d > tbody > tr > td,.gssb_e,.gssb_e > tbody > tr,.gssb_e > tbody > tr > td{padding:0;margin:0;border:0}.gssb_a table,.gssb_a table tr,.gssb_a table tr td{padding:0;margin:0;border:0}</style></head> <body><div role="dialog" aria-live="polite" aria-label="cookieconsent" aria-describedby="cookieconsent:desc" class="cc-window cc-banner cc-type-info cc-theme-block cc-bottom cc-color-override-688238583 " style=""><!--googleoff: all--><span id="cookieconsent:desc" class="cc-message">This website uses cookies to ensure you get the best experience on our website. <a aria-label="learn more about cookies" role="button" tabindex="0" class="cc-link" href="http://cookiesandyou.com/" target="_blank">Learn more</a></span><div class="cc-compliance"><a aria-label="dismiss cookie message" role="button" tabindex="0" class="cc-btn cc-dismiss">Got it!</a></div><!--googleon: all--></div> <style type="text/css"> article a { text-decoration: none } .mdl-menu { min-width: 1024px; } .mdl-menu__item { height: 24px; line-height: 24px } .header_notice a{ color: #fff } </style> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-21234995-1', 'auto'); ga('send', 'pageview'); </script> <script> window.addEventListener("load", function(){ window.cookieconsent.initialise({ "palette": { "popup": { "background": "#000" }, "button": { "background": "#f1d600" } } })}); </script> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <div class="mdl-layout mdl-layout--fixed-header"> <header class="mdl-layout__header"> <div class="mdl-layout__header-row"> <a href="https://www.w3resource.com/" style="text-decoration: none;"><span class="mdl-layout-title" style="margin-left: -50px;margin-top: -5px;color:#fff">w3resource</span></a> <button id="main-menu-lower-right" class="mdl-button mdl-js-button mdl-button--icon" data-upgraded=",MaterialButton"> <i class="material-icons">menu</i> </button> <nav class="mdl-navigation mdl-layout--large-screen-only"> <div class="mdl-menu__container is-upgraded"><div class="mdl-menu__outline"></div><div class="mdl-grid mdl-menu mdl-cell-mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect mdl-js-ripple-effect--ignore-events" style="width: 100%; overflow-x:hidden;height:360px;overflow-y: scroll" for="main-menu-lower-right" data-upgraded=",MaterialMenu,MaterialRipple"> <div class="mdl-cell mdl-cell--3-col"> <ul> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Front End<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/html/HTML-tutorials.php">HTML</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/css/CSS-tutorials.php">CSS</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/javascript/javascript.php">JavaScript</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/html5/introduction.php">HTML5</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/schema.org/introduction.php">Schema.org</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/phpjs/use-php-functions-in-javascript.php">php.js</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/twitter-bootstrap/tutorial.php">Twitter Bootstrap</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/responsive-web-design/overview.php">Responsive Web Design tutorial</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/zurb-foundation3/introduction.php">Zurb Foundation 3 tutorials</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/pure/">Pure CSS</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/html5-canvas/">HTML5 Canvas</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/course/javascript-course.html" target="_blank">JavaScript Course</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/icon/">Icon</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Linux<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/linux-system-administration/installation.php">Linux Home</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/linux-system-administration/linux-commands-introduction.php">Linux Commands</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/linux-system-administration/installation.php">Linux Server Administration</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> </ul> </div> <div class="mdl-cell mdl-cell--3-col"> <ul> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Back End<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/php/php-home.php">PHP</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/python/python-tutorial.php">Python</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/java-tutorial/">Java</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/node.js/node.js-tutorials.php">Node.js</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/ruby/">Ruby</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/c-programming/programming-in-c.php">C programming</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">SQL &amp; RDBMS<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/sql/tutorials.php">SQL(2003 standard of ANSI)</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/mysql/mysql-tutorials.php">MySQL</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/PostgreSQL/tutorial.php">PostgreSQL</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/sqlite/">SQLite</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">NoSQL &amp; MongoDB<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/mongodb/nosql.php">NoSQL</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/mongodb/nosql.php">MongoDB</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">API<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/google-plus/tutorial.php">Google Plus API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/youtube/tutorial.php">Youtube API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/google-maps/index.php">Google Maps API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/flickr/tutorial.php">Flickr API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/last.fm/tutorial.php">Last.fm API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/API/twitter-rest-api/">Twitter REST API</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> </ul> </div> <div class="mdl-cell mdl-cell--3-col"> <ul> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Data Interchnage<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/xml/xml.php">XML</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/JSON/introduction.php">JSON</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/ajax/introduction.php">Ajax</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Exercises<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/html-css-exercise/index.php">HTML CSS Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/javascript-exercises/">JavaScript Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/jquery-exercises/">jQuery Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/jquery-ui-exercises/">jQuery-UI Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/coffeescript-exercises/">CoffeeScript Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/php-exercises/">PHP Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/python-exercises/">Python Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/c-programming-exercises/">C Programming Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/csharp-exercises/">C# Sharp Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/java-exercises/">Java Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/sql-exercises/">SQL Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/oracle-exercises/">Oracle Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/mysql-exercises/">MySQL Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/sqlite-exercises/">SQLite Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/postgresql-exercises/">PostgreSQL Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/mongodb-exercises/">MongoDB Exercises</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/twitter-bootstrap/examples.php">Twitter Bootstrap Examples</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/euler-project/">Euler Project</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> </ul> </div> <div class="mdl-cell mdl-cell--3-col"> <ul> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Quiz<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/html5-quiz/">HTML5 Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/php-fundamentals/">PHP Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/sql-beginner/">SQL Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/python-beginner-quiz/">Python Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/mysql-basic-quiz/">MySQL Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/javascript-basic-skill-test/">JavaScript I Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/javascript-advanced-quiz/">JavaScript II Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/javascript-quiz-part-iii/">JavaScript III Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://w3resource.com/w3skills/mongodb-basic-quiz/">MongoDB Quiz</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Form Template<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/form-template/">Forms Template</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Slides<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/slides/">Slides Presentation</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Google Docs<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/form-template/">Forms Template</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/slides/">Slide Presentation</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Conversion Tools<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/convert/number/binary-to-decimal.php">Number Conversion</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">MS Excel<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/excel/">Excel 2013 tutorial</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Videos<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/video-tutorial/php/some-basics-of-php.php">PHP Videos</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/video-tutorial/javascript/list-of-tutorial.php">JavaScript Videos</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" style="color:#f86d1d;height:24px; line-height: 24px" tabindex="-1" data-upgraded=",MaterialRipple">Tools<span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/web-development-tools/firebug-tutorials.php">Firebug Tutorial</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-cell--12-col mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.w3resource.com/web-development-tools/useful-web-development-tools.php">Useful Tools</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> </ul> </div> </div></div> </nav> <div class="np"><span class="previousNext"><a href="https://www.w3resource.com/java-exercises/index.php"><i class="material-icons" style="margin-left: 40px; color: rgb(255, 255, 255); vertical-align: middle;">skip_previous</i></a><a href="https://www.w3resource.com/java-exercises/datatypes/index.php"><i class="material-icons" style="margin-left: 30px; color: rgb(255, 255, 255); vertical-align: middle;">skip_next</i></a></span></div> <div class="mdl-layout-spacer"></div> <div class="header_notice"><a href="https://goo.gl/forms/WdU5vlk4PeMKs4bi1" target="_blank">Help us improve w3resource. Please take this survey.</a></div> <div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield--floating-label mdl-textfield--align-right is-upgraded" data-upgraded=",MaterialTextfield"> <div class="mdl-textfield__expandable-holder"> <input class="mdl-textfield__input" type="text" name="sample" id="fixed-header-drawer-exp"> </div> </div> <nav class="mdl-navigation mdl-layout--large-screen-only"> <style type="text/css"> .gsc-control-cse { height:20px; background-color: rgb(63,81,181); border:0; margin-top: -15px; !important; } .gsc-control-cse-en { height:20px; background-color: rgb(63,81,181); border:0; margin-top: -15px; !important; } </style> <div class="customSearch" style="border:0px solid;margin:-20px;width:400px;height:auto;"> <script> (function() { var cx = '013584948386948090933:pjqiqxq1drs'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = 'https://cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <div id="___gcse_0"><div class="gsc-control-cse gsc-control-cse-en"><div class="gsc-control-wrapper-cse" dir="ltr"><form class="gsc-search-box gsc-search-box-tools" accept-charset="utf-8"><table cellspacing="0" cellpadding="0" class="gsc-search-box"><tbody><tr><td class="gsc-input"><div class="gsc-input-box " id="gsc-iw-id1"><table cellspacing="0" cellpadding="0" id="gs_id50" class="gstl_50 " style="width: 100%; padding: 0px;"><tbody><tr><td id="gs_tti50" class="gsib_a"><input autocomplete="off" type="text" size="10" class="gsc-input" name="search" title="search" id="gsc-i-id1" x-webkit-speech="" x-webkit-grammar="builtin:search" lang="en" dir="ltr" spellcheck="false" placeholder="Custom Search" style="width: 100%; padding: 0px; border: none; margin: 0px; height: auto; outline: none; background: url(&quot;https://www.google.com/cse/static/images/1x/googlelogo_lightgrey_46x16dp.png&quot;) left center no-repeat rgb(255, 255, 255); text-indent: 48px;"></td><td class="gsib_b"><div class="gsst_b" id="gs_st50" dir="ltr"><a class="gsst_a" href="javascript:void(0)" style="display: none;"><span class="gscb_a" id="gs_cb50">×</span></a></div></td></tr></tbody></table></div></td><td class="gsc-search-button"><input type="image" src="./Bai5_files/search_box_icon.png" class="gsc-search-button gsc-search-button-v2" title="search"></td><td class="gsc-clear-button"><div class="gsc-clear-button" title="clear results">&nbsp;</div></td></tr></tbody></table><table cellspacing="0" cellpadding="0" class="gsc-branding"><tbody><tr><td class="gsc-branding-user-defined"></td><td class="gsc-branding-text"><div class="gsc-branding-text">powered by</div></td><td class="gsc-branding-img"><img src="./Bai5_files/googlelogo_grey_46x15dp.png" class="gsc-branding-img" srcset="https://www.google.com/cse/static/images/2x/googlelogo_grey_46x15dp.png 2x"></td></tr></tbody></table></form><div class="gsc-results-wrapper-overlay"><div class="gsc-results-close-btn" tabindex="0"></div><div class="gsc-tabsAreaInvisible"><div class="gsc-tabHeader gsc-inline-block gsc-tabhActive">Web</div><span class="gs-spacer"> </span><div tabindex="0" class=" gsc-tabHeader gsc-tabhInactive gsc-inline-block">Image</div><span class="gs-spacer"> </span></div><div class="gsc-refinementsAreaInvisible"></div><div class="gsc-above-wrapper-area-invisible"><table cellspacing="0" cellpadding="0" class="gsc-above-wrapper-area-container"><tbody><tr><td class="gsc-result-info-container"><div class="gsc-result-info-invisible"></div></td><td class="gsc-orderby-container"><div class="gsc-orderby-invisible"><div class="gsc-orderby-label gsc-inline-block">Sort by:</div><div class="gsc-option-menu-container gsc-inline-block"><div class="gsc-selected-option-container gsc-inline-block"><div class="gsc-selected-option">Relevance</div><div class="gsc-option-selector"></div></div><div class="gsc-option-menu-invisible"><div class="gsc-option-menu-item gsc-option-menu-item-highlighted"><div class="gsc-option">Relevance</div></div><div class="gsc-option-menu-item"><div class="gsc-option">Date</div></div></div></div></div></td></tr></tbody></table></div><div class="gsc-adBlockInvisible"></div><div class="gsc-wrapper"><div class="gsc-adBlockInvisible"></div><div class="gsc-resultsbox-invisible"><div class="gsc-resultsRoot gsc-tabData gsc-tabdActive"><table cellspacing="0" cellpadding="0" class="gsc-resultsHeader"><tbody><tr><td class="gsc-twiddleRegionCell"><div class="gsc-twiddle"><div class="gsc-title">Web</div></div><div class="gsc-stats"></div><div class="gsc-results-selector gsc-all-results-active"><div class="gsc-result-selector gsc-one-result" title="show one result">&nbsp;</div><div class="gsc-result-selector gsc-more-results" title="show more results">&nbsp;</div><div class="gsc-result-selector gsc-all-results" title="show all results">&nbsp;</div></div></td><td class="gsc-configLabelCell"></td></tr></tbody></table><div><div class="gsc-expansionArea"></div></div></div><div class="gsc-resultsRoot gsc-tabData gsc-tabdInactive"><table cellspacing="0" cellpadding="0" class="gsc-resultsHeader"><tbody><tr><td class="gsc-twiddleRegionCell"><div class="gsc-twiddle"><div class="gsc-title">Image</div></div><div class="gsc-stats"></div><div class="gsc-results-selector gsc-all-results-active"><div class="gsc-result-selector gsc-one-result" title="show one result">&nbsp;</div><div class="gsc-result-selector gsc-more-results" title="show more results">&nbsp;</div><div class="gsc-result-selector gsc-all-results" title="show all results">&nbsp;</div></div></td><td class="gsc-configLabelCell"></td></tr></tbody></table><div><div class="gsc-expansionArea"></div></div></div></div></div></div><div class="gsc-modal-background-image" tabindex="0"></div></div></div></div> </div> <button id="demo-menu-lower-right" class="mdl-button mdl-js-button mdl-button--icon" data-upgraded=",MaterialButton"> <i class="material-icons">share</i> </button> <div class="mdl-menu__container is-upgraded"><div class="mdl-menu__outline mdl-menu--bottom-right"></div><ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect mdl-js-ripple-effect--ignore-events" for="demo-menu-lower-right" style="overflow-y:scroll;min-width:200px" data-upgraded=",MaterialMenu,MaterialRipple"> <li class="mdl-menu__item mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://www.facebook.com/w3resource">Facebook</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://twitter.com/w3resource">Twitter</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://plus.google.com/+W3resource">Google Plus</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://in.linkedin.com/in/w3resource">Linkedin</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> <li class="mdl-menu__item mdl-js-ripple-effect" tabindex="-1" data-upgraded=",MaterialRipple"><a href="https://feeds.feedburner.com/W3resource">RSS</a><span class="mdl-menu__item-ripple-container"><span class="mdl-ripple"></span></span></li> </ul></div> </nav> </div> </header> <main class="mdl-layout__content"> <div class="page-content"> <div class="mdl-grid"> <div class="mdl-cell mdl-cell--3-col mdl-cell--hide-phone"> <a href="https://www.w3resource.com/"><img src="./Bai5_files/w3resource-logo.png" alt="w3resource logo"></a></div> <div class="mdl-cell mdl-cell--9-col mdl-cell--hide-phone"> <script type="text/javascript" language="javascript" src="./Bai5_files/getads.js.tải xuống"></script> <script type="text/javascript" language="javascript"> //<![CDATA[ aax_getad_mpb({ "slot_uuid":"0f1f9886-d533-461c-9bb1-b200b3e51a83" }); //]]> </script><script src="./Bai5_files/getad"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <!-- top-banner --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-2153208817642134" data-ad-slot="6584603516" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent;"><ins id="aswift_0_anchor" style="display:block;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent;"><iframe width="728" height="90" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;width:728px;height:90px;" src="./Bai5_files/saved_resource.html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="mdl-grid"> <div class="mdl-cell mdl-cell--12-col mdl-card mdl-shadow--2dp through mdl-shadow--6dp mdl-cell--hide-phone"> <p> New exercises added to: <a href="https://www.w3resource.com/ruby-exercises/">Ruby, </a><a href="https://www.w3resource.com/java-exercises/">Java, </a><a href="https://www.w3resource.com/php-exercises/">PHP, </a> <a href="https://www.w3resource.com/python-exercises/">Python, </a><a href="https://www.w3resource.com/c-programming-exercises/">C Programming, </a> <a href="https://www.w3resource.com/graphics/matplotlib/">Matplotlib, </a><a href="https://www.w3resource.com/python-exercises/numpy/index.php">Python NumPy, </a><a href="https://www.w3resource.com/python-exercises/pandas/index.php">Python Pandas</a></p> </div> </div> <div class="mdl-grid"> <div class="mdl-cell mdl-card mdl-shadow--2dp through mdl-shadow--6dp mdl-cell--2-col mdl-cell--hide-phone"> <ul class="nav nav-list"><li><a href="https://www.w3resource.com/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement">Home</a></li><li class="nav-header">▼Java Exercises</li><li><a href="https://www.w3resource.com/java-exercises/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Introduction</a></li><li class="active"><a href="https://www.w3resource.com/java-exercises/basic/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement">Basic</a></li><li><a href="https://www.w3resource.com/java-exercises/datatypes/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Data Types</a></li><li><a href="https://www.w3resource.com/java-exercises/conditional-statement/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Conditional Statement</a></li><li><a href="https://www.w3resource.com/java-exercises/array/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Array</a></li><li><a href="https://www.w3resource.com/java-exercises/string/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> String</a></li><li><a href="https://www.w3resource.com/java-exercises/datetime/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Date Time</a></li><li><a href="https://www.w3resource.com/java-exercises/method/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Method</a></li><li><a href="https://www.w3resource.com/java-exercises/numbers/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Numbers</a></li><li><a href="https://www.w3resource.com/java-exercises/io/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Input-Output File System</a></li><li><a href="https://www.w3resource.com/java-exercises/collection/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Collection</a></li><li><a href="https://www.w3resource.com/java-exercises/math/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> Math</a></li><li><a href="https://www.w3resource.com/java-exercises/basic/index.php" itemscope="" itemtype="http://schema.org/WebPageElement/SiteNavigationElement"> ..More to come..</a></li></ul> </div> <div class="mdl-cell mdl-card mdl-shadow--2dp through mdl-shadow--6dp mdl-cell--7-col"> <article itemscope="" itemtype="http://schema.org/TechArticle"> <img src="./Bai5_files/java-exercises.png" alt="Java Programming Exercises"> <h1 itemscope="" itemtype="http://schema.org/WebPageElement/Heading" class="heading" id="h_one">Java Basic Programming : Exercises, Practice, Solution</h1> <time itemprop="dateModified" datetime="February 27 2018 12:54:51.">Last update on February 27 2018 12:54:51 (UTC/GMT +8 hours)</time> <div class="mdl-grid"> <div class="mdl-cell mdl-cell--12-col mdl-cell--hide-phone mdl-cell--hide-tablet"> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> </div> <div class="mdl-cell mdl-cell--12-col mdl-cell--hide-desktop"> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display:inline-block;width:320px;height:100px" data-ad-client="ca-pub-2153208817642134" data-ad-slot="7685555518" data-adsbygoogle-status="done"><ins id="aswift_1_expand" style="display:inline-table;border:none;height:100px;margin:0;padding:0;position:relative;visibility:visible;width:320px;background-color:transparent;"><ins id="aswift_1_anchor" style="display: block; border: none; height: 100px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 320px; background-color: transparent; overflow: visible; opacity: 1;"><iframe width="320" height="100" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;width:320px;height:100px;" src="./Bai5_files/saved_resource(3).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <h2>Java Basic Exercises [117 exercises with solution]</h2> <p class="heading">[<em>An editor is available at the bottom of the page to write and execute the scripts.</em>] </p> <p><strong>1.</strong> Write a Java program to print 'Hello' on screen and then print your name on a separate line. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em> :<br> Hello <br> Alexandra Abramov</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-1.php" target="_blank">Click me to see the solution</a></p> <p><strong>2.</strong> Write a Java program to print the sum of two numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: <br> 74 + 36 <br> <em>Expected Output</em> :<br> 110</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-2.php" target="_blank">Click me to see the solution</a></p> <p><strong>3.</strong> Write a Java program to divide two numbers and print on the screen. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data : <br> 50/3<br> <em>Expected Output</em> :<br> 16</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-3.php" target="_blank">Click me to see the solution</a></p> <p><strong>4.</strong> Write a Java program to print the result of the following operations. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> a. -5 + 8 * 6<br> b. (55+9) % 9 <br> c. 20 + -3*5 / 8 <br> d. 5 + 15 / 3 * 2 - 8 % 3 <br> <em>Expected Output</em> :<br> 43 <br> 1 <br> 19 <br> 13</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-4.php" target="_blank">Click me to see the solution</a></p> <p><strong>5.</strong> Write a Java program that takes two numbers as input and display the product of two numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> Input first number: 25<br> Input second number: 5<br> <em>Expected Output</em> :<br> 25 x 5 = 125</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-5.php" target="_blank">Click me to see the solution</a></p> <p><strong>6.</strong> Write a Java program to print the sum (addition), multiply, subtract, divide and remainder of two numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> Input first number: 125<br> Input second number: 24<br> <em>Expected Output</em> :<br> 125 + 24 = 149<br> 125 - 24 = 101<br> 125 x 24 = 3000<br> 125 / 24 = 5<br> 125 mod 24 = 5</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-6.php" target="_blank">Click me to see the solution</a></p> <p><strong>7.</strong> Write a Java program that takes a number as input and prints its multiplication table upto 10. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> Input a number: 8<br> <em>Expected Output</em> :<br> 8 x 1 = 8<br> 8 x 2 = 16<br> 8 x 3 = 24<br> ...<br> 8 x 10 = 80</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-7.php" target="_blank"> Click me to see the solution</a></p> <p><strong>8.</strong> Write a Java program to display the following pattern. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Pattern : </em></p> <pre> J a v v a J a a v v a a J J aaaaa V V aaaaa JJ a a V a a </pre> <p> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-8.php" target="_blank">Click me to see the solution</a></p> <p><strong>9.</strong> Write a Java program to compute the specified expressions and print the output. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> ((25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5)) <br> <em>Expected Output</em><br> 2.138888888888889</p> <p> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-9.php" target="_blank">Click me to see the solution</a></p> <p></p> <p> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display: block; text-align: center; height: 200px;" data-ad-format="fluid" data-ad-layout="in-article" data-ad-client="ca-pub-2153208817642134" data-ad-slot="1566153117" data-adsbygoogle-status="done"><ins id="aswift_2_expand" style="display:inline-table;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><ins id="aswift_2_anchor" style="display:block;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><iframe width="882" height="200" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_2" name="aswift_2" style="left:0;position:absolute;top:0;width:882px;height:200px;" src="./Bai5_files/saved_resource(4).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></p> <p></p> <p><strong>10.</strong> Write a Java program to compute a specified formula. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Specified Formula :</em> <br> 4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11))<br> <em>Expected Output</em><br> 2.9760461760461765</p> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-10.php" target="_blank">Click me to see the solution</a></p> <p><strong>11.</strong> Write a Java program to print the area and perimeter of a circle. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> Radius = 7.5 <br> <em>Expected Output</em><br> Perimeter is = 47.12388980384689 <br> Area is = 176.71458676442586 </p> <p> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-11.php" target="_blank">Click me to see the solution</a></p> <p><strong>12.</strong> Write a Java program that takes three numbers as input to calculate and print the average of the numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-12.php" target="_blank">Click me to see the solution</a></p> <p><strong>13.</strong> Write a Java program to print the area and perimeter of a rectangle. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Test Data:</em><br> Width = 5.5 Height = 8.5 </p> <p><em>Expected Output</em><br> Area is 5.6 * 8.5 = 47.60<br> Perimeter is 2 * (5.6 + 8.5) = 28.20 </p> <p> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-13.php" target="_blank">Click me to see the solution</a></p> <p><strong>14.</strong> Write a Java program to print an American flag on the screen. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>* * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== * * * * * ================================== * * * * * * ================================== ============================================== ============================================== ============================================== ============================================== ============================================== ============================================== </pre> <p> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-14.php" target="_blank">Click me to see the solution</a></p> <p><strong>15.</strong> Write a Java program to swap two variables. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-15.php" target="_blank">Click me to see the solution</a></p> <p><strong>16.</strong> Write a Java program to print a face. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre> +"""""+ [| o o |] | ^ | | '-' | +-----+ </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-16.php" target="_blank">Click me to see the solution</a></p> <p><strong>17.</strong> Write a Java program to add two binary numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input first binary number: 10 <br> Input second binary number: 11<br> <em>Expected Output</em></p> <pre>Sum of two binary numbers: 101 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-17.php" target="_blank">Click me to see the solution</a></p> <p><strong>18.</strong> Write a Java program to multiply two binary numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input the first binary number: 10 <br> Input the second binary number: 11 <br> <em>Expected Output</em></p> <pre>Product of two binary numbers: 110 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-18.php" target="_blank">Click me to see the solution</a></p> <p><strong>19.</strong> Write a Java program to convert a decimal number to binary number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a Decimal Number : 5<br> <em>Expected Output</em></p> <pre>Binary number is: 101 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-19.php" target="_blank">Click me to see the solution</a></p> <p><strong>20.</strong> Write a Java program to convert a decimal number to hexadecimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a decimal number: 15<br> <em>Expected Output</em></p> <pre>Hexadecimal number is : F </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-20.php" target="_blank">Click me to see the solution</a></p> <p><strong>21.</strong> Write a Java program to convert a decimal number to octal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a Decimal Number: 15 <br> <em>Expected Output</em></p> <pre>Octal number is: 17 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-21.php" target="_blank">Click me to see the solution</a></p> <p><strong>22.</strong> Write a Java program to convert a binary number to decimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a binary number: 100<br> <em>Expected Output</em></p> <pre>Decimal Number: 4 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-22.php" target="_blank">Click me to see the solution</a></p> <p><strong>23.</strong> Write a Java program to convert a binary number to hexadecimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a Binary Number: 1101 <br> <em>Expected Output</em></p> <pre>HexaDecimal value: D </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-23.php" target="_blank">Click me to see the solution</a></p> <p><strong>24.</strong> Write a Java program to convert a binary number to a Octal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a Binary Number: 111 <br> <em>Expected Output</em></p> <pre>Octal number: 7 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-24.php" target="_blank">Click me to see the solution</a></p> <p><strong>25.</strong> Write a Java program to convert a octal number to a decimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input any octal number: 10 <br> <em>Expected Output</em></p> <pre>Equivalent decimal number: 8 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-25.php" target="_blank">Click me to see the solution</a></p> <p><strong>26.</strong> Write a Java program to convert a octal number to a binary number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input any octal number: 7 <br> <em>Expected Output</em></p> <pre>Equivalent binary number: 111 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-26.php" target="_blank">Click me to see the solution</a></p> <p><strong>27.</strong> Write a Java program to convert a octal number to a hexadecimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a octal number : 100 <br> <em>Expected Output</em></p> <pre>Equivalent hexadecimal number: 40 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-27.php" target="_blank">Click me to see the solution</a></p> <p><strong>28.</strong> Write a Java program to convert a hexadecimal to a decimal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a hexadecimal number: 25<br> <em>Expected Output</em></p> <pre>Equivalent decimal number is: 37 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-28.php" target="_blank">Click me to see the solution</a></p> <p><strong>29.</strong> Write a Java program to convert a hexadecimal to a binary number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Enter Hexadecimal Number : 37<br> <em>Expected Output</em></p> <pre>Equivalent Binary Number is: 110111 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-29.php" target="_blank">Click me to see the solution</a></p> <p></p> <p> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display: block; text-align: center; height: 200px;" data-ad-format="fluid" data-ad-layout="in-article" data-ad-client="ca-pub-2153208817642134" data-ad-slot="4519619511" data-adsbygoogle-status="done"><ins id="aswift_3_expand" style="display:inline-table;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><ins id="aswift_3_anchor" style="display:block;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><iframe width="882" height="200" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_3" name="aswift_3" style="left:0;position:absolute;top:0;width:882px;height:200px;" src="./Bai5_files/saved_resource(5).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </p> <p></p> <p><strong>30.</strong> Write a Java program to convert a hexadecimal to a octal number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a hexadecimal number: 40<br> <em>Expected Output</em></p> <pre>Equivalent of octal number is: 100 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-30.php" target="_blank">Click me to see the solution</a></p> <p><strong>31.</strong> Write a Java program to check whether Java is installed on your computer. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>Java Version: 1.8.0_71 Java Runtime Version: 1.8.0_71-b15 Java Home: /opt/jdk/jdk1.8.0_71/jre Java Vendor: Oracle Corporation Java Vendor URL: http://Java.oracle.com/ Java Class Path: . </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-31.php" target="_blank">Click me to see the solution</a></p> <p><strong>32.</strong> Write a Java program to compare two numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input first integer: 25<br> Input second integer: 39<br> <em>Expected Output</em></p> <pre>25 != 39 25 &lt; 39 25 &lt;= 39 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-32.php" target="_blank">Click me to see the solution</a></p> <p><strong>33.</strong> Write a Java program and compute the sum of the digits of an integer. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input an integer: 25<br> <em>Expected Output</em></p> <pre>The sum of the digits is: 7 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-33.php" target="_blank">Click me to see the solution</a></p> <p><strong>34.</strong> Write a Java program to compute the area of a hexagon. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Area of a hexagon = (6 * s^2)/(4*tan(π/6))<br> where s is the length of a side<br> Input Data:<br> Input the length of a side of the hexagon: 6<br> <em>Expected Output</em></p> <pre>The area of the hexagon is: 93.53074360871938 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-34.php" target="_blank">Click me to see the solution</a></p> <p><strong>35.</strong> Write a Java program to compute the area of a polygon. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Area of a polygon = (n*s^2)/(4*tan(π/n))<br> where n is n-sided polygon and s is the length of a side<br> Input Data:<br> Input the number of sides on the polygon: 7<br> Input the length of one of the sides: 6<br> <em>Expected Output</em></p> <pre>The area is: 130.82084798405722 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-35.php" target="_blank">Click me to see the solution</a></p> <p><strong>36.</strong> Write a Java program to compute the distance between two points on the surface of earth. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Distance between the two points [ (x1,y1) &amp; (x2,y2)]<br> d = radius * arccos(sin(x1) * sin(x2) + cos(x1) * cos(x2) * cos(y1 - y2))<br> Radius of the earth r = 6371.01 Kilometers<br> Input Data:<br> Input the latitude of coordinate 1: 25 <br> Input the longitude of coordinate 1: 35<br> Input the latitude of coordinate 2: 35.5<br> Input the longitude of coordinate 2: 25.5<br> <em>Expected Output</em></p> <pre style="overflow: scroll">The distance between those points is: 1480.0848451069087 km </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-36.php" target="_blank">Click me to see the solution</a></p> <p><strong>37.</strong> Write a Java program to reverse a string. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input Data:<br> Input a string: The quick brown fox <br> <em>Expected Output</em></p> <pre>Reverse string: xof nworb kciuq ehT </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-37.php" target="_blank">Click me to see the solution</a></p> <p><strong>38.</strong> Write a Java program to count the letters, spaces, numbers and other characters of an input string. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre style="overflow: scroll">The string is : Aa kiu, I swd skieo 236587. GH kiu: sieo?? 25.33 letter: 23 space: 9 number: 10 other: 6 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-38.php" target="_blank">Click me to see the solution</a></p> <p><strong>39.</strong> Write a Java program to create and display unique three-digit number using 1, 2, 3, 4. Also count how many three-digit numbers are there. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>123 124 ... 431 432 Total number of the three-digit-number is 24 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-39.php" target="_blank">Click me to see the solution</a></p> <p><strong>40.</strong> Write a Java program to list the available character sets in charset objects. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>List of available character sets: Big5 Big5-HKSCS CESU-8 EUC-JP EUC-KR GB18030 GB2312 GBK ... x-SJIS_0213 x-UTF-16LE-BOM X-UTF-32BE-BOM X-UTF-32LE-BOM x-windows-50220 x-windows-50221 x-windows-874 x-windows-949 x-windows-950 x-windows-iso2022jp </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-40.php" target="_blank">Click me to see the solution</a></p> <p><strong>41.</strong> Write a Java program to print the ascii value of a given character. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>The ASCII value of Z is :90 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-41.php" target="_blank">Click me to see the solution</a></p> <p><strong>42.</strong> Write a Java program to input and display your password. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Expected Output</em></p> <pre>Input your Password: Your password was: abc@123 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-42.php" target="_blank">Click me to see the solution</a></p> <p><strong>43.</strong> Write a Java program to print the following string in a specific format (see the output). <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output</em></p> <pre>Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-43.php" target="_blank">Click me to see the solution</a></p> <p><strong>44.</strong> Write a Java program that accepts an integer (n) and computes the value of n+nn+nnn. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input number: 5 5 + 55 + 555 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-44.php" target="_blank">Click me to see the solution</a></p> <p><strong>45.</strong> Write a Java program to find the size of a specified file. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>/home/students/abc.txt : 0 bytes /home/students/test.txt : 0 bytes </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-45.php" target="_blank">Click me to see the solution</a></p> <p><strong>46.</strong> Write a Java program to display the system time. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Current Date time: Fri Jun 16 14:17:40 IST 2017 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-46.php" target="_blank">Click me to see the solution</a></p> <p><strong>47.</strong> Write a Java program to display the current date time in specific format. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Now: 2017/06/16 08:52:03.066 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-47.php" target="_blank">Click me to see the solution</a></p> <p><strong>48.</strong> Write a Java program to print the odd numbers from 1 to 99. Prints one number per line. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>1 3 5 7 9 11 .... 91 93 95 97 99 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-48.php" target="_blank">Click me to see the solution</a></p> <p><strong>49.</strong> Write a Java program to accept a number and check the number is even or not. Prints 1 if the number is even or 0 if the number is odd. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input a number: 20 1 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-49.php" target="_blank">Click me to see the solution</a></p> <p><strong>50.</strong> Write a Java program to print numbers between 1 to 100 which are divisible by 3, 5 and by both. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Divided by 3: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57 , 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, Divided by 5: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, Divided by 3 &amp; 5: 15, 30, 45, 60, 75, 90, </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-50.php" target="_blank">Click me to see the solution</a></p> <p><strong>51.</strong> Write a Java program to convert a string to an integer in Java. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input a number(string): 25 The integer value is: 25 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-51.php" target="_blank">Click me to see the solution</a></p> <p><strong>52.</strong> Write a Java program to calculate the sum of two integers and return true if the sum is equal to a third integer. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 5 Input the second number: 10 Input the third number : 15 The result is: true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-52.php" target="_blank">Click me to see the solution</a></p> <p><strong>53.</strong> Write a Java program that accepts three integers from the user and return true if the second number is greater than first number and third number is greater than second number. If "abc" is true second number does not need to be greater than first number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 5 Input the second number: 10 Input the third number : 15 The result is: true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-53.php" target="_blank">Click me to see the solution</a></p> <p><strong>54.</strong> Write a Java program that accepts three integers from the user and return true if two or more of them (integers ) have the same rightmost digit. The integers are non-negative. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 5 Input the second number: 10 Input the third number : 15 The result is: true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-54.php" target="_blank">Click me to see the solution</a></p> <p><strong>55.</strong> Write a Java program to convert seconds to hour, minute and seconds. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input seconds: 86399 23:59:59 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-55.php" target="_blank">Click me to see the solution</a></p> <p><strong>56.</strong> Write a Java program to find the number of integers within the range of two specified numbers and that are divisible by another number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> For example x = 5, y=20 and p =3, find the number of integers within the range x..y and that are divisible by p i.e. { i :x ≤ i ≤ y, i mod p = 0 }<br> <em>Sample Output: </em></p> <pre>5 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-56.php" target="_blank">Click me to see the solution</a></p> <p><strong>57.</strong> Write a Java program to accepts an integer and count the factors of the number. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input an integer: 25 3 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-57.php" target="_blank">Click me to see the solution</a></p> <p><strong>58.</strong> Write a Java program to capitalize the first letter of each word in a sentence. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Input a Sentence: the quick brown fox jumps over the lazy dog. The Quick Brown Fox Jumps Over The Lazy Dog. </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-58.php" target="_blank">Click me to see the solution</a></p> <p><strong>59.</strong> Write a Java program to convert a given string into lowercase. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Input a String: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-59.php" target="_blank">Click me to see the solution</a></p> <p></p> <p> <script data-cfasync="false" src="./Bai5_files/email-decode.min.js.tải xuống"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display: block; text-align: center; height: 200px;" data-ad-format="fluid" data-ad-layout="in-article" data-ad-client="ca-pub-2153208817642134" data-ad-slot="5996352715" data-adsbygoogle-status="done"><ins id="aswift_4_expand" style="display:inline-table;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><ins id="aswift_4_anchor" style="display:block;border:none;height:200px;margin:0;padding:0;position:relative;visibility:visible;width:882px;background-color:transparent;"><iframe width="882" height="200" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_4" name="aswift_4" style="left:0;position:absolute;top:0;width:882px;height:200px;" src="./Bai5_files/saved_resource(6).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </p> <p></p> <p><strong>60.</strong> Write a Java program to find the penultimate (next to last) word of a sentence. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Input a String: The quick brown fox jumps over the lazy dog. Penultimate word: lazy </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-60.php" target="_blank">Click me to see the solution</a></p> <p><strong>61.</strong> Write a Java program to reverse a word. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input a word: dsaf Reverse word: fasd </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-61.php" target="_blank">Click me to see the solution</a></p> <p><strong>62.</strong> Write a Java program that accepts three integer values and return true if one of them is 20 or more less than one of the others. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 15 Input the second number: 20 Input the third number : 25 false </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-62.php" target="_blank">Click me to see the solution</a></p> <p><strong>63.</strong> Write a Java program that accepts two integer values from the user and return the larger values. However if the two values are the same, return 0 and return the smaller value if the two values have the same remainder when divided by 6. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 12 Input the second number: 13 Result: 13 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-63.php" target="_blank">Click me to see the solution</a></p> <p><strong>64.</strong> Write a Java program that accepts two integer values between 25 to 75 and return true if there is a common digit in both numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 35 Input the second number: 45 Result: true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-64.php" target="_blank">Click me to see the solution</a></p> <p><strong>65.</strong> Write a Java program to calculate the modules of two numbers without using any inbuilt modulus operator. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Input the first number : 19 Input the second number: 7 5 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-65.php" target="_blank">Click me to see the solution</a></p> <p><strong>66.</strong> Write a Java program to compute the sum of the first 100 prime numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Sum of the first 100 prime numbers: 24133 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-66.php" target="_blank">Click me to see the solution</a></p> <p><strong>67.</strong> Write a Java program to insert a word in the middle of the another string. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>Insert "Tutorial" in the middle of "Python 3.0", so result will be Python Tutorial 3.0<br> <em>Sample Output: </em></p> <pre>Python Tutorial 3.0 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-67.php" target="_blank">Click me to see the solution</a></p> <p><strong>68.</strong> Write a Java program to create a new string of 4 copies of the last 3 characters of the original string. The length of the original string must be 3 and above. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>3.03.03.03.0 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-68.php" target="_blank">Click me to see the solution</a></p> <p><strong>69.</strong> Write a Java program to extract the first half of a string of even length. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: Python<br> <em>Sample Output: </em><br> </p><pre>Pyt</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-69.php" target="_blank">Click me to see the solution</a></p> <p><strong>70.</strong> Write a Java program to create a string in the form short_string + long_string + short_string from two strings. The strings must not have the same length. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: Str1 = Python<br> Str2 = Tutorial<br> <em>Sample Output: </em></p> <pre>PythonTutorialPython</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-70.php" target="_blank">Click me to see the solution</a></p> <p><strong>71.</strong> Write a Java program to create the concatenation of the two strings except removing the first character of each string. The length of the strings must be 1 and above. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: Str1 = Python<br> Str2 = Tutorial<br> <em>Sample Output: </em></p> <pre>ythonutorial</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-71.php" target="_blank">Click me to see the solution</a></p> <p><strong>72.</strong> Write a Java program to create a new string taking first three characters from a given string. If the length of the given string is less than 3 use "#" as substitute characters. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: Str1 = " "<br> <em>Sample Output: </em></p> <pre>###</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-72.php" target="_blank">Click me to see the solution</a></p> <p><strong>73.</strong> Write a Java program to create a new string taking first and last characters from two given strings. If the length of either string is 0 use "#" for missing character. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: str1 = "Python"<br> str2 = " "<br> <em>Sample Output: </em></p> <pre>P#</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-73.php" target="_blank">Click me to see the solution</a></p> <p><strong>74.</strong> Write a Java program to test if 10 appears as either the first or last element of an array of integers. The length of the array must be greater than or equal to 2. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em><br> Test Data: array = 10, -20, 0, 30, 40, 60, 10</p> <pre>true</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-74.php" target="_blank">Click me to see the solution</a></p> <p><strong>75.</strong> Write a Java program to test if the first and the last element of an array of integers are same. The length of the array must be greater than or equal to 2. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: array = 50, -20, 0, 30, 40, 60, 10<br> <em>Sample Output: </em></p> <pre>false</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-75.php" target="_blank">Click me to see the solution</a></p> <p><strong>76.</strong> Write a Java program to test if the first and the last element of two array of integers are same. The length of the array must be greater than or equal to 2. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>Test Data: array1 = 50, -20, 0, 30, 40, 60, 12<br> array2 = 45, 20, 10, 20, 30, 50, 11<br> <em>Sample Output: </em></p> <pre>false</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-76.php" target="_blank">Click me to see the solution</a></p> <p><strong>77.</strong> Write a Java program to create a new array of length 2 from two arrays of integers with three elements and the new array will contain the first and last elements from the two arrays. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test Data: array1 = 50, -20, 0<br> array2 = 5, -50, 10<br> <em>Sample Output: </em></p> <pre>Array1: [50, -20, 0] Array2: [5, -50, 10] New Array: [50, 10]</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-77.php" target="_blank">Click me to see the solution</a></p> <p><strong>78.</strong> Write a Java program to test that a given array of integers of length 2 contains a 4 or a 7. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Original Array: [5, 7] true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-78.php" target="_blank">Click me to see the solution</a></p> <p><strong>79.</strong> Write a Java program to rotate an array (length 3) of integers in left direction. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Original Array: [20, 30, 40] Rotated Array: [30, 40, 20]</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-79.php" target="_blank">Click me to see the solution</a></p> <p><strong>80.</strong> Write a Java program to get the larger value between first and last element of an array (length 3) of integers . <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Original Array: [20, 30, 40] Larger value between first and last element: 40 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-80.php" target="_blank">Click me to see the solution</a></p> <p><strong>81.</strong> Write a Java program to swap the first and last elements of an array (length must be at least 1) and create a new array. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Original Array: [20, 30, 40] New array after swaping the first and last elements: [40, 30, 20] </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-81.php" target="_blank">Click me to see the solution</a></p> <p><strong>82.</strong> Write a Java program to find the largest element between first, last, and middle values from an array of integers (even length). <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre style="overflow: scroll">Original Array: [20, 30, 40, 50, 67] Largest element between first, last, and middle values: 67 </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-82.php" target="_blank">Click me to see the solution</a></p> <p><strong>83.</strong> Write a Java program to multiply corresponding elements of two arrays of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <em>Sample Output: </em></p> <pre>Array1: [1, 3, -5, 4] Array2: [1, 4, -5, -2] Result: 1 12 25 -8</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-83.php" target="_blank">Click me to see the solution</a></p> <p><strong>84.</strong> Write a Java program to take the last three characters from a given string and add the three characters at both the front and back of the string. String length must be greater than three and more. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Test data: "Python" will be "honPythonhon"<br> <em>Sample Output: </em></p> <pre>PyPythonPy</pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-84.php" target="_blank">Click me to see the solution</a></p> <p><strong>85.</strong> Write a Java program to check if a string starts with a specified word. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>Sample Data: string1 = "Hello how are you?"<br> <em>Sample Output: </em></p> <pre class="output">true </pre> <p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-85.php" target="_blank">Click me to see the solution</a></p> <p><strong>86.</strong> Write a Java program start with an integer n, divide n by 2 if n is even or multiply by 3 and add 1 if n is odd, repeat the process until n = 1. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> </p><p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-86.php" target="_blank">Click me to see the solution</a></p> <p><strong>87.</strong> Write a Java program than read an integer and calculate the sum of its digits and write the number of each digit of the sum in English. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> </p><p><a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-87.php" target="_blank">Click me to see the solution</a></p> <p><strong>88.</strong> Write a Java program to get the current system environment and system properties. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-88.php" target="_blank">Click me to see the solution</a></p> <p><strong>89.</strong> Write a Java program to check whether a security manager has already been established for the current application or not. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-89.php" target="_blank">Click me to see the solution</a></p> <p><strong>90.</strong> Write a Java program to get the value of the environment variable PATH, TEMP, USERNAME. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-90.php" target="_blank">Click me to see the solution</a></p> <p><strong>91.</strong> Write a Java program to measure how long some code takes to execute in nanoseconds. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-91.php" target="_blank">Click me to see the solution</a></p> <p><strong>92.</strong> Write a Java program to count the number of even and odd elements in a given array of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-92.php" target="_blank">Click me to see the solution</a></p> <p><strong>93.</strong> Write a Java program to test if an array of integers contains an element 10 next to 10 or an element 20 next to 20, but not both. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-93.php" target="_blank">Click me to see the solution</a></p> <p><strong>94.</strong> Write a Java program to rearrange all the elements of an given array of integers so that all the odd numbers come before all the even numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-94.php" target="_blank">Click me to see the solution</a></p> <p><strong>95.</strong> Write a Java program to create an array (length # 0) of string values. The elements will contain "0", "1", "2" … through ... n-1. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-95.php" target="_blank">Click me to see the solution</a></p> <p><strong>96.</strong> Write a Java program to check if there is a 10 in a given array of integers with a 20 somewhere later in the array. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-96.php" target="_blank">Click me to see the solution</a></p> <p><strong>97.</strong> Write a Java program to check if an array of integers contains a specified number next to each other or there are two same specified numbers separated by one element. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-97.php" target="_blank">Click me to see the solution</a></p> <p><strong>98.</strong> Write a Java program to check if the value 20 appears three times and no 20's are next to each other in an given array of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-98.php" target="_blank">Click me to see the solution</a></p> <p><strong>99.</strong> Write a Java program to check if a specified number appears in every pair of adjacent element of a given array of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-99.php" target="_blank">Click me to see the solution</a></p> <p><strong>100.</strong> Write a Java program to count the two elements differ by 1 or less of two given arrays of integers with same length. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-100.php" target="_blank">Click me to see the solution</a></p> <p><strong>101.</strong> Write a Java program to check if the number of 10 is greater than number to 20's in a given array of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-101.php" target="_blank">Click me to see the solution</a></p> <p><strong>102.</strong> Write a Java program to check if a specified array of integers contains 10's or 30's. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-102.php" target="_blank">Click me to see the solution</a></p> <p><strong>103.</strong> Write a Java program to create a new array from a given array of integers, new array will contain the elements from the given array after the last element value 10. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-103.php" target="_blank">Click me to see the solution</a></p> <p><strong>104.</strong> Write a Java program to create a new array from a given array of integers, new array will contain the elements from the given array before the last element value 10. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-104.php" target="_blank">Click me to see the solution</a></p> <p><strong>105.</strong> Write a Java program to check if a group of numbers (l) at the start and end of a given array are same. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-105.php" target="_blank">Click me to see the solution</a></p> <p><strong>106.</strong> Write a Java program to create a new array that is left shifted from a given array of integers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-106.php" target="_blank">Click me to see the solution</a></p> <p><strong>107.</strong> Write a Java program to check if an array of integers contains three increasing adjacent numbers. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-107.php" target="_blank">Click me to see the solution</a></p> <p><strong>108.</strong> Write a Java program to add all the digits of a given positive integer until the result has a single digit. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-108.php" target="_blank">Click me to see the solution</a></p> <p><strong>109.</strong> Write a Java program to form a staircase shape of n coins where every k-th row must have exactly k coins. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-109.php" target="_blank">Click me to see the solution</a></p> <p><strong>110.</strong> Write a Java program to check whether an given integer is a power of 4 or not. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Given num = 64, return true. Given num = 6, return false.<br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-110.php" target="_blank">Click me to see the solution</a></p> <p><strong>111.</strong> Write a Java program to add two numbers without using any arithmetic operators. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>Given x = 10 and y = 12; result = 22<br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-111.php" target="_blank">Click me to see the solution</a></p> <p><strong>112.</strong> Write a Java program to compute the number of trailing zeros in a factorial. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>7! = 5040, therefore the output should be 1<br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-112.php" target="_blank">Click me to see the solution</a></p> <p><strong>113.</strong> Write a Java program to merge two given sorted array of integers and create a new sorted array. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>array1 = [1,2,3,4]<br> array2 = [2,5,7, 8]<br> result = [1,2,2,3,4,5,7,8]<br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-113.php" target="_blank">Click me to see the solution</a></p> <p><strong>114.</strong> Write a Java program to given a string and an offset, rotate string by offset (rotate from left to right). <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-114.php" target="_blank">Click me to see the solution</a></p> <p><strong>115.</strong> Write a Java program to check if a positive number is a palindrome or not. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> Input a positive integer: 151 <br> Is 151 is a palindrome number? <br> true<br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-115.php" target="_blank">Click me to see the solution</a></p> <p><strong>116.</strong> Write a Java program which iterates the integers from 1 to 100. For multiples of three print "Fizz" instead of the number and print "Buzz" for the multiples of five. When number is divided by both three and five, print "fizz buzz". <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-116.php" target="_blank">Click me to see the solution</a></p> <p><strong>117.</strong> Write a Java program to compute the square root of an given integer. <a href="https://www.w3resource.com/java-exercises/basic/index.php#editorr">Go to the editor</a><br>Input a positive integer: 25<br> Square root of 25 is: 5 <br> <a href="https://www.w3resource.com/java-exercises/basic/java-basic-exercise-117.php" target="_blank">Click me to see the solution</a></p> <p id="editorr"><strong>Java Code Editor:</strong></p> <p> <iframe src="./Bai5_files/d1fcaa7e44.html" width="100%" height="600" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen=""></iframe></p> <p class="style2"><strong>More to Come !</strong></p> <p class="style2"><strong>Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.</strong></p> </article> <style type="text/css"> .notes { margin-left:20% } .notes a { color: #e51cc9 } </style> <p class="notes"><a href="https://goo.gl/forms/WdU5vlk4PeMKs4bi1" target="_blank">Help us improve w3resource. Please take this survey.</a></p> <hr class="w3r_hr"> <div class="mdl-grid"> <div id="bottom_ad_zero_google" class="mdl-cell mdl-cell--6-col mdl-cell--hide-phone"> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display: inline-block; width: 300px; height: 250px;" data-ad-client="ca-pub-2153208817642134" data-ad-slot="4616214717" data-adsbygoogle-status="done"><ins id="aswift_5_expand" style="display:inline-table;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><ins id="aswift_5_anchor" style="display:block;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe width="300" height="250" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_5" name="aswift_5" style="left:0;position:absolute;top:0;width:300px;height:250px;" src="./Bai5_files/saved_resource(7).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div id="bottom_ad_one_amazon-cpm" class="mdl-cell mdl-cell--6-col mdl-cell--hide-phone"> <script type="text/javascript" language="javascript" src="./Bai5_files/getads.js.tải xuống"></script> <script type="text/javascript" language="javascript"> //<![CDATA[ aax_getad_mpb({ "slot_uuid":"e0a1a470-d3e8-45e4-a0fa-fdf2a8cac69e" }); //]]> </script><script src="./Bai5_files/getad(1)"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <!-- 300X250_bellow_content --> <ins class="adsbygoogle" style="display: inline-block; width: 300px; height: 250px;" data-ad-client="ca-pub-2153208817642134" data-ad-slot="4616214717" data-adsbygoogle-status="done"><ins id="aswift_6_expand" style="display:inline-table;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><ins id="aswift_6_anchor" style="display:block;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe width="300" height="250" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_6" name="aswift_6" style="left:0;position:absolute;top:0;width:300px;height:250px;" src="./Bai5_files/saved_resource(8).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div id="bottom_ad_zero_amazon" class="mdl-cell mdl-cell--hide-desktop"> <script type="text/javascript" language="javascript" src="./Bai5_files/getads.js.tải xuống"></script> <script type="text/javascript" language="javascript"> //<![CDATA[ aax_getad_mpb({ "slot_uuid":"6a527ea5-0510-4a70-af94-358c7bda61b8" }); //]]> </script><script src="./Bai5_files/getad(2)"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <!-- responsive_bellow_content --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-2153208817642134" data-ad-slot="9162288711" data-ad-format="auto" data-adsbygoogle-status="done"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div id="disqus_thread"><iframe id="dsq-app1348" name="dsq-app1348" allowtransparency="true" frameborder="0" scrolling="no" tabindex="0" title="Disqus" width="100%" src="./Bai5_files/saved_resource(9).html" style="width: 1px !important; min-width: 100% !important; border: none !important; overflow: hidden !important; height: 2226px !important;" horizontalscrolling="no" verticalscrolling="no"></iframe></div> <div id="disqus_thread" itemscope="" itemtype="http://schema.org/CreativeWork/Comment"></div> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = 'w3r'; // required: replace example with your forum shortname // The following are highly recommended additional parameters. Remove the slashes in front to use. // var disqus_identifier = 'unique_dynamic_id_1234'; // var disqus_url = 'http://example.com/permalink-to-page.html'; /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <div id="bottom_ad" style="display: block; background-color:#f8f8f8; margin-top: 30px"> </div> </div> <div class="mdl-cell mdl-card mdl-shadow--2dp through mdl-shadow--6dp mdl-cell--3-col mdl-cell--hide-phone"> <div id="sol_ad_zero"> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:600px" data-ad-client="ca-pub-2153208817642134" data-ad-slot="6376961513" data-adsbygoogle-status="done"><ins id="aswift_7_expand" style="display:inline-table;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><ins id="aswift_7_anchor" style="display:block;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe width="300" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_7" name="aswift_7" style="left:0;position:absolute;top:0;width:300px;height:600px;" src="./Bai5_files/saved_resource(10).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div id="sol_ad_one"> <script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:600px" data-ad-client="ca-pub-2153208817642134" data-ad-slot="6965701915" data-adsbygoogle-status="done"><ins id="aswift_8_expand" style="display:inline-table;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><ins id="aswift_8_anchor" style="display:block;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe width="300" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_8" name="aswift_8" style="left:0;position:absolute;top:0;width:300px;height:600px;" src="./Bai5_files/saved_resource(11).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div id="sol_ad_two"> <script type="text/javascript" language="javascript" src="./Bai5_files/getads.js.tải xuống"></script> <script type="text/javascript" language="javascript"> //<![CDATA[ aax_getad_mpb({ "slot_uuid":"d7e99008-686f-462a-a349-68f0492859b1" }); //]]> </script><script src="./Bai5_files/getad(3)"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <!-- sol_ad_two --> <ins class="adsbygoogle" style="display: block; height: 280px;" data-ad-client="ca-pub-2153208817642134" data-ad-slot="1165650718" data-ad-format="auto" data-adsbygoogle-status="done"><ins id="aswift_9_expand" style="display:inline-table;border:none;height:280px;margin:0;padding:0;position:relative;visibility:visible;width:376px;background-color:transparent;"><ins id="aswift_9_anchor" style="display:block;border:none;height:280px;margin:0;padding:0;position:relative;visibility:visible;width:376px;background-color:transparent;"><iframe width="376" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_9" name="aswift_9" style="left:0;position:absolute;top:0;width:376px;height:280px;" src="./Bai5_files/saved_resource(12).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div id="sol_ad_three"> <script type="text/javascript" language="javascript" src="./Bai5_files/getads.js.tải xuống"></script> <script type="text/javascript" language="javascript"> //<![CDATA[ aax_getad_mpb({ "slot_uuid":"2fc7138b-e045-4ed0-a6b6-e6e6103eca45" }); //]]> </script><script src="./Bai5_files/getad(4)"></script><script async="" src="./Bai5_files/adsbygoogle.js.tải xuống"></script> <!-- 300X600_rightbar --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:600px" data-ad-client="ca-pub-2153208817642134" data-ad-slot="6376961513" data-adsbygoogle-status="done"><ins id="aswift_10_expand" style="display:inline-table;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><ins id="aswift_10_anchor" style="display:block;border:none;height:600px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe width="300" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_10" name="aswift_10" style="left:0;position:absolute;top:0;width:300px;height:600px;" src="./Bai5_files/saved_resource(13).html"></iframe></ins></ins></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> <footer class="mdl-mega-footer"> <div class="mdl-mega-footer__bottom-section"> <div class="mdl-logo"><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US" target="_blank">This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</a></div> </div> <div class="mdl-mega-footer__bottom-section"> <div class="mdl-logo">©w3resource.com 2011-2018</div> <ul class="mdl-mega-footer__link-list"> <li><a href="https://www.w3resource.com/privacy.php">Privacy</a></li> <li><a href="https://www.w3resource.com/about.php">About</a></li> <li><a href="https://www.w3resource.com/contact.php">Contact</a></li> <li><a href="https://www.w3resource.com/feedback.php">Feedback</a></li> <li><a href="https://www.w3resource.com/advertise.php">Advertise</a></li> </ul> </div> </footer> </main> </div><iframe style="display: none;" src="./Bai5_files/saved_resource(14).html"></iframe> <link rel="stylesheet" href="./Bai5_files/icon"><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-0" src="./Bai5_files/saved_resource(15).html"></iframe></div> <script src="./Bai5_files/material.min.js.tải xuống"></script> <link rel="stylesheet" href="./Bai5_files/prism.css"> <script src="./Bai5_files/prism.js.tải xuống"></script> <script> var goTop = document.createElement("a"); goTop.innerHTML = '<i class="material-icons">&#xE5D8;</i>'; goTop.style = "bottom:0;right:27%;position:absolute;z-index: 9999"; goTop.setAttribute("href", "#h_one"); document.body.appendChild(goTop); </script><a href="https://www.w3resource.com/java-exercises/basic/index.php#h_one" style="bottom: 0px; right: 27%; position: absolute; z-index: 9999;"><i class="material-icons"></i></a> <link rel="stylesheet" type="text/css" href="./Bai5_files/cookieconsent.min.css"> <script src="./Bai5_files/cookieconsent.min.js.tải xuống"></script> <script> window.onload = function() { //var old_links = document.getElementById("np").style.display = "none"; var links = document.querySelector("ul.nav.nav-list").childNodes; var parentDiv = document.querySelector(".np"); //var prne_bottom = document.getElementById("previousnext_bottom"); var node = document.createElement("span"); node.setAttribute("class","previousNext"); parentDiv.appendChild(node); for (var i=0; i < links.length; i++) { if(links[i].getAttribute("class")!=="nav-header" && links[i].children[0].getAttribute('href')===window.location.pathname){ if(links[i-1].getAttribute("class")!=="nav-header"){ var newLink = document.createElement("a"); newLink.setAttribute("href",links[i-1].children[0].getAttribute("href")); var icon = document.createElement("i"); icon.setAttribute("class","material-icons"); icon.style.marginLeft = '40px'; icon.style.color = '#fff'; icon.style.verticalAlign = 'middle'; var previousTxt = document.createTextNode('skip_previous'); icon.appendChild(previousTxt); newLink.appendChild(icon); node.appendChild(newLink); } else if (links[i-1].getAttribute("class")==="nav-header"){ var newLink = document.createElement("a"); newLink.setAttribute("href",links[i-2].children[0].getAttribute("href")); var icon = document.createElement("i"); icon.setAttribute("class","material-icons"); icon.style.marginLeft = '40px'; icon.style.color = '#fff'; icon.style.verticalAlign = 'middle'; var previousTxt = document.createTextNode('skip_previous'); icon.appendChild(previousTxt); newLink.appendChild(icon); node.appendChild(newLink); } if(links[i+1].getAttribute("class")!=="nav-header") { var newLink = document.createElement("a"); newLink.setAttribute("href",links[i+1].children[0].getAttribute("href")); var icon = document.createElement("i"); icon.setAttribute("class","material-icons"); icon.style.marginLeft = '30px'; icon.style.color = '#fff'; icon.style.verticalAlign = 'middle'; var nextTxt = document.createTextNode('skip_next'); icon.appendChild(nextTxt); newLink.appendChild(icon); node.appendChild(newLink); } else if (links[i+1].getAttribute("class")==="nav-header") { var newLink = document.createElement("a"); newLink.setAttribute("href",links[i+2].children[0].getAttribute("href")); var icon = document.createElement("i"); icon.setAttribute("class","material-icons"); icon.style.marginLeft = '30px'; icon.style.color = '#fff'; icon.style.verticalAlign = 'middle'; var nextTxt = document.createTextNode('skip_next'); icon.appendChild(nextTxt); newLink.appendChild(icon); node.appendChild(newLink); } } } var prenext = document.querySelector("span.previousNext"); var cln = prenext.cloneNode(true); //var prenextBottom = document.getElementById("previousnext_bottom"); //prenextBottom.appendChild(cln); } </script> <script src="./Bai5_files/onejs"></script><div id="amzn_assoc_ad_div_adunit_0"></div> <div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-1" src="./Bai5_files/saved_resource(16).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-2" src="./Bai5_files/saved_resource(17).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-3" src="./Bai5_files/saved_resource(18).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-4" src="./Bai5_files/saved_resource(19).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-5" src="./Bai5_files/saved_resource(20).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-6" src="./Bai5_files/saved_resource(21).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-7" src="./Bai5_files/saved_resource(22).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-8" src="./Bai5_files/saved_resource(23).html"></iframe></div><div style="display: none;"><iframe frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" class="goog_xca_frame" style="opacity: 0; transition: none; overflow: visible;" id="_no-clickjacking-9" src="./Bai5_files/saved_resource(24).html"></iframe></div><table cellspacing="0" cellpadding="0" class="gstl_50 gssb_c" style="width: 291px; display: none; top: 43px; position: absolute; left: 1121px;"><tbody><tr><td class="gssb_f"></td><td class="gssb_e" style="width: 100%;"></td></tr></tbody></table></body></html>
ccc89eb3fcd64bb840120e097ac580081fa46144
d7a5b159345cc4993cce311ae908cad80ef351b6
/src/main/java/com/cafe24/guestbook/dao/GuestbookDao.java
459202a099b351ad4e40645515b2ace7b1a33980
[]
no_license
MaximSungmo/guestbook
dbec670767a2ebaff21c4170c1025cdb56febf7d
1df6dada15375efdb9d9779a63047e442ef00c47
refs/heads/master
2020-05-23T13:25:04.574142
2019-05-15T07:49:32
2019-05-15T07:49:32
186,776,413
1
0
null
null
null
null
UTF-8
Java
false
false
4,599
java
package com.cafe24.guestbook.dao; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import com.cafe24.guestbook.vo.GuestbookVo; public class GuestbookDao { private Connection getConnection() throws SQLException { Connection conn = null; // 1. JDBC Driver(MariaDB) 로딩 // 직접 코드로 메소드Area에 로딩할 때 try { Class.forName("org.mariadb.jdbc.Driver"); // 2. 연결하기 String url = "jdbc:mariadb://192.168.1.41:3307/webdb"; // DriverManager.getConnection을 하면 Connection 인터페이스의 conn이 구현된다. conn = DriverManager.getConnection(url, "webdb", "webdb"); } catch (ClassNotFoundException e) { System.out.println("드라이버 로딩 실패" + e); } return conn; } public List<GuestbookVo> getList() { List<GuestbookVo> result = new ArrayList<GuestbookVo>(); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { conn = getConnection(); // 3. statement 객체 생성 String sql = "select no, name, contents, date_format(reg_date, '%Y-%m-%d %h:%i:%s') from guestbook order by reg_date;"; pstmt = conn.prepareStatement(sql); // 4. SQL문 실행 rs = pstmt.executeQuery(); // 5. 결과 가져오기 // rs 값 중 다음 값이 없다면 false이므로 while문이 멈춘다. while (rs.next()) { Long no = rs.getLong(1); String name = rs.getString(2); String contents = rs.getString(3); String regDate = rs.getString(4); GuestbookVo vo = new GuestbookVo(); vo.setNo(no); vo.setName(name); vo.setContents(contents); vo.setRegDate(regDate); result.add(vo); } } catch (SQLException e) { System.out.println("error" + e); } finally { try { if (rs != null) { rs.close(); } if (pstmt != null) { pstmt.close(); } if (conn != null) { // 연결 종료 conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } return result; } // category의 정보를 insert하는 메소드 public Boolean insert(GuestbookVo vo) { // 사용자의 정보가 제대로 업데이트가 된 경우 result = true로 메소드 종료 아니면 SQLException 오류 발생 boolean result = false; Connection conn = null; PreparedStatement pstmt = null; try { // connection을 위한 클래스를 별도로 작성하여 conn 변수에 넣어줌 conn = getConnection(); String sql = "insert into guestbook values(null, ?,?,?,now());"; pstmt = conn.prepareStatement(sql); // SQL의 ?를 받기 위한 바인딩 작업 pstmt.setString(1, vo.getName()); pstmt.setString(2, vo.getPassword()); pstmt.setString(3, vo.getContents()); // 준비된 내용을 실행하여 데이터베이스 업데이트 진행 int count = pstmt.executeUpdate(); result = (count == 1); } catch (SQLException e) { System.out.println("error" + e); } finally { try { if (pstmt != null) { pstmt.close(); } if (conn != null) { // 연결 종료 conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } return result; } public Boolean delete(GuestbookVo vo) { // 사용자의 정보가 제대로 업데이트가 된 경우 result = true로 메소드 종료 아니면 SQLException 오류 발생 boolean result = false; Connection conn = null; PreparedStatement pstmt = null; try { // connection을 위한 클래스를 별도로 작성하여 conn 변수에 넣어줌 conn = getConnection(); String sql = "delete from guestbook where no=? and name = ?"; pstmt = conn.prepareStatement(sql); // SQL의 ?를 받기 위한 바인딩 작업 pstmt.setLong(1, vo.getNo()); pstmt.setString(1, vo.getName()); // 준비된 내용을 실행하여 데이터베이스 업데이트 진행 int count = pstmt.executeUpdate(); result = (count == 1); } catch (SQLException e) { System.out.println("error" + e); } finally { try { if (pstmt != null) { pstmt.close(); } if (conn != null) { // 연결 종료 conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } return result; } }
[ "bit@DESKTOP-H5F1754" ]
bit@DESKTOP-H5F1754
75e784d9883dfd78a26ab637250a89ad85e92a43
1dd0a714b3c24c30e92f09ca0b1ffe055cfc869a
/Module01/src/com/qian/bean/Customer.java
9fa161610be250940211297606cb07e83d69e437
[]
no_license
qianzebin/workspace_idea
72b9664557788ed907d0ef064a3a09fff21f680b
a5b30fdba9e15f6a13c9384e64043d35f0fc6333
refs/heads/master
2020-09-22T10:41:56.470155
2019-12-01T12:42:32
2019-12-01T12:42:32
225,159,491
1
0
null
null
null
null
UTF-8
Java
false
false
374
java
package com.qian.bean; //这是啥 public class Customer { public static void main(String[] args){ System.out.print("Hello World!!!"); } @Override public boolean equals(Object obj) { return super.equals(obj); } /** * yes * @return */ @Override public int hashCode() { return super.hashCode(); } }
bdfad88ae585a53492328859e522a63e9b1750d7
ccc1b9d1f60e92aaf50a69a76003924788653973
/app/src/main/java/com/kitestart/thenetwork/View/UserListAdapder.java
450b1de6624be68b608672e9c19965e130afcfea
[]
no_license
sorunokoe/TheNetworkAndroidExample
068df9c591fecb74edc6938cea7b9776b97d0821
80276138977b16266ebb76008560e25834425a0d
refs/heads/master
2020-03-10T14:18:21.743076
2018-04-16T15:48:57
2018-04-16T15:48:57
129,422,988
0
0
null
null
null
null
UTF-8
Java
false
false
1,473
java
package com.kitestart.thenetwork.View; import android.content.Context; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import com.kitestart.thenetwork.Model.UserModel; import com.kitestart.thenetwork.R; import org.w3c.dom.Text; import java.util.ArrayList; import java.util.List; public class UserListAdapder extends ArrayAdapter<UserModel>{ private Context mContext; private List<UserModel> userList; public UserListAdapder(Context context, ArrayList<UserModel> list) { super(context, 0 , list); mContext = context; userList = list; } @NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View listItem = convertView; if(listItem == null){ listItem = LayoutInflater.from(mContext).inflate(R.layout.list_item, parent, false); } UserModel user = userList.get(position); TextView name = listItem.findViewById(R.id.nameTextView); TextView status = listItem.findViewById(R.id.statusTextView); name.setText( user.getName() ); status.setText( user.getStatus() ); return listItem; } }
75472b1c38c763980f0ca249dce983a8c89a0f77
b4ee1933ddbf87e19fa5d5fc7fd495fd4eca029c
/riptide-core/src/main/java/org/zalando/riptide/Navigator.java
2baa62942f520da5e9053e91625f641e51510ad8
[ "MIT" ]
permissive
snurmine/riptide
c4466d7f001bbcbfcdb104d7c2b85cdb519f340d
d29669e426fbce276d5ab3e8a94d98c14d5eef39
refs/heads/master
2021-01-25T09:52:42.234339
2018-02-27T13:27:02
2018-02-27T13:27:02
123,323,333
0
0
MIT
2018-02-28T18:11:34
2018-02-28T18:11:33
null
UTF-8
Java
false
false
1,288
java
package org.zalando.riptide; import com.google.common.reflect.TypeToken; import org.springframework.http.client.ClientHttpResponse; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; /** * A Navigator chooses among the {@link Binding bindings} of a {@link RoutingTree routing tree}. The act of traversing * a routing tree by choosing a binding and following its {@link Binding#getRoute() associated route} is called * nested dispatch. * * @param <A> generic attribute type */ @FunctionalInterface public interface Navigator<A> { default TypeToken<A> getType() { return new TypeToken<A>(getClass()) {}; } Optional<Route> navigate(final ClientHttpResponse response, final RoutingTree<A> tree) throws IOException; default List<Binding<A>> merge(final List<Binding<A>> present, final List<Binding<A>> additional) { final Map<A, Binding<A>> bindings = new LinkedHashMap<>(present.size() + additional.size()); present.forEach(binding -> bindings.put(binding.getAttribute(), binding)); additional.forEach(binding -> bindings.put(binding.getAttribute(), binding)); return new ArrayList<>(bindings.values()); } }
c4fa37eb0aa53d0c50493f81eae5a0d3139992be
2edcbb0936bd1890521ccc5a90b7f24ed2f111f2
/src/day22_NestedLoops/CashRegister.java
3d23054f7714a6fcb09b082578f34777da010efd
[]
no_license
avsararas/Eclipse_Basic
64be84da032e003c897afce36e1be4caea049a86
e85ca81fca409bcd81cd079f4726b7d51b9b25ef
refs/heads/master
2020-04-17T21:16:13.484867
2019-01-27T17:22:02
2019-01-27T17:22:02
166,942,087
0
0
null
null
null
null
UTF-8
Java
false
false
642
java
package day22_NestedLoops; import java.util.Scanner; public class CashRegister { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("How Many Items do you buy?"); int itemcount=scan.nextInt(); double price; int total=0; String item=""; for (int num = 1; num < itemcount; num++) { System.out.println("What is item " +num); item=scan.next(); System.out.println("Hom much is " +item+ "?"); price=scan.nextDouble(); total+=price; } System.out.println("Your total is: "+total ); scan.close(); } }
6bbde6cad29740c63e54e5ceed0c2635b055bdb8
2e93cb33f4a4e946635031c608d9b693ef10fde1
/JSP/myapp/src/hok/OrderBean.java
07958fd124875a6528b222cc5da520794484be37
[]
no_license
kw78999/MyStudy
34b5718125a30f6835056f02c716b5d2d6e84472
adb34fc5a423c6ae5761a404de1157fc95b93047
refs/heads/main
2023-04-11T00:44:28.668482
2021-04-23T05:11:00
2021-04-23T05:11:00
305,602,182
1
0
null
null
null
null
UTF-8
Java
false
false
2,259
java
package hok; public class OrderBean { private int ordNum; private int proNum; private String id; private String pwd; private String email; private String ordPhone; private int ordAm; private String payMe; private String state; private String payName; private String devAddress; private String zipcode; private String devName; private String devPhone; private String ordDay; private String payDay; public int getOrdNum() { return ordNum; } public void setOrdNum(int ordNum) { this.ordNum = ordNum; } public int getProNum() { return proNum; } public void setProNum(int proNum) { this.proNum = proNum; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getOrdPhone() { return ordPhone; } public void setOrdPhone(String ordPhone) { this.ordPhone = ordPhone; } public int getOrdAm() { return ordAm; } public void setOrdAm(int ordAm) { this.ordAm = ordAm; } public String getPayMe() { return payMe; } public void setPayMe(String payMe) { this.payMe = payMe; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getPayName() { return payName; } public void setPayName(String payName) { this.payName = payName; } public String getDevAddress() { return devAddress; } public void setDevAddress(String devAddress) { this.devAddress = devAddress; } public String getZipcode() { return zipcode; } public void setZipcode(String zipcode) { this.zipcode = zipcode; } public String getDevName() { return devName; } public void setDevName(String devName) { this.devName = devName; } public String getDevPhone() { return devPhone; } public void setDevPhone(String devPhone) { this.devPhone = devPhone; } public String getOrdDay() { return ordDay; } public void setOrdDay(String ordDay) { this.ordDay = ordDay; } public String getPayDay() { return payDay; } public void setPayDay(String payDay) { this.payDay = payDay; } }
cdb16d254e0bb073a61e6fc0dcea40f929dae356
eec56e35bb8b4234c213f9f0d763b5cdc40a1ffc
/src/abd/pr1/mappers/VotoEpisodioMapper.java
a69de1a08f447a624c66d39bfa9bb7fc4d791bd5
[ "MIT" ]
permissive
davbolan/Gestor-de-series
9ac8a09c9acd8a4fcb3d6cdc034cbd4026b3e945
a02cff6b7f0788f9c02edf92ceb97e6fb75034aa
refs/heads/master
2021-01-13T08:28:39.519863
2016-10-26T18:45:31
2016-10-26T18:45:31
71,845,239
0
1
null
2016-10-26T18:27:42
2016-10-25T00:52:36
Java
UTF-8
Java
false
false
1,589
java
package abd.pr1.mappers; import java.sql.ResultSet; import java.sql.SQLException; import javax.sql.DataSource; import abd.pr1.tiposDeDatos.VotoEpisodio; public class VotoEpisodioMapper extends AbstractMapper<VotoEpisodio, Integer>{ private static final String[] VOTO_EPISODIO_KEY_COLUMN_NAMES = new String[] { "id" }; private static final String[] VOTO_EPISODIO_COLUMN_NAMES = new String[] { "id", "fecha", "texto", "nickUsuario", "idEpisodio"}; private static final String VOTO_EPISODIO_TABLE_NAME = "votoepisodio"; public VotoEpisodioMapper(DataSource ds) { super(ds); } @Override protected String getTableName() { return VOTO_EPISODIO_TABLE_NAME; } @Override protected String[] getColumnNames() { return VOTO_EPISODIO_COLUMN_NAMES; } @Override protected Object[] serializeObject(VotoEpisodio object) { return new Object[] { object.getId(), object.getIdEpisodio(), object.getNota(), object.getNickUsuario() }; } @Override protected String[] getKeyColumnNames() { return VOTO_EPISODIO_KEY_COLUMN_NAMES; } @Override protected Object[] serializeKey(Integer key) { return new Object[] { key }; } @Override protected VotoEpisodio buildObject(ResultSet rs) throws SQLException { Integer id = rs.getInt("id"); String nickUsuario = rs.getString("nickUsuario"); Integer idEpisodio = rs.getInt("idEpisodio"); Integer nota = rs.getInt("nota"); return new VotoEpisodio(id, idEpisodio, nota, nickUsuario); } @Override protected Integer getKey(VotoEpisodio object) { return object.getId(); } }
8b3aed2dc31e19f7a6c7159d8e5f919e51719efa
bcf8da723c8fc73a64677a78c78f68e6826e7966
/corpusCreator/org.aspectj.modules.tests.src.org.aspectj.systemtest.purejava.java
1e6799fa81252e31b7397a354e45897ebce8ff7b
[ "Apache-2.0" ]
permissive
shy942/LSIimplementationPython
f552f3da6677bf703003dffdbedda26c996d8d8c
692fe04ba1ad40e3629fc248e914d6a48bf0f0f0
refs/heads/master
2020-04-07T00:59:51.096366
2019-01-11T21:44:45
2019-01-11T21:44:45
157,927,147
0
0
null
null
null
null
UTF-8
Java
false
false
2,315
java
copyright corporation all this common public license file test based ajc test case pure java tests based ajc test case test based ajc test case suite pure java tests file spec file file java java test test for statement test test test test test test test doesn test test make test full test making test not test test throwable test test exception test null pointer exception test test exception test test error test error test string test test test test test test test can test test undefined test test test r591 test jacks test test test test test test test test test overruning starts test test test test test test test test test test test test test test test test accessing test crashes test crashes test crashes test crashes system test crashes test two test crashes test crashes test crashes test stray test colon test test circular test missing test test new array exprs test test implementing test test test test test referencing test some test test test test test test test test test test test r584 can test test test test test test test test test test parent test test test test test test test test test test test test test test test verify error test test test test test test test test referencing test referencing test referencing test referencing test referencing test referencing test referencing test referencing test test test test test strings test cast test boundary test state test test test test various test abstract test test test test the aspect test more test more test looking java string test looking java string test looking java string test looking java string test testing test lifting test getting test not test test test checking test trouble test binding test not test members test fully test fully test calls test reading test reading test reading test not test not test resolving test assignments test conflicting test test test test test test test test test packages test inner public default test default test returning test flow test test test implicit test inners test primitives test parenthesized test field test constant test local test binops test can test testing test test test test test test test test test test test test test test test test operands test test test test test cannot test test locals test test test test test test test test test test scanner test crashes
d968d22d8253b7197af0daa7e6b17d560d453a7d
9448485ab7745b6407cd5f8918936db1009d466d
/src/main/java/com/cheeray/mq/MQConsumer.java
63ad3aea858b28e115c744c71175e7dd45a97d9e
[ "Apache-2.0" ]
permissive
cheeray/jms-rest
675f26d5207824716891fd163ebe9619dcba8b9e
ddf7325da017c39e5b6b5a15a24e25626ff5e199
refs/heads/master
2021-01-22T23:33:19.325750
2017-03-21T04:40:28
2017-03-21T04:40:28
85,648,844
3
0
null
null
null
null
UTF-8
Java
false
false
8,500
java
package com.cheeray.mq; import java.io.IOException; import java.lang.invoke.MethodHandle; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.cheeray.exception.CollectionException; import com.cheeray.jms.QueueConfig; import com.cheeray.jms.annotation.BackoutMode; import com.ibm.mq.MQEnvironment; import com.ibm.mq.MQException; import com.ibm.mq.MQGetMessageOptions; import com.ibm.mq.MQMessage; import com.ibm.mq.MQPoolToken; import com.ibm.mq.MQQueue; import com.ibm.mq.MQQueueManager; import com.ibm.mq.constants.CMQC; import com.ibm.mq.constants.MQConstants; import com.ibm.mq.headers.MQHeader; import com.ibm.mq.headers.MQHeaderIterator; /** * Consume MQ messages and convert them into a string with char(256). * * @author Chengwei.Yan * */ public class MQConsumer extends Thread { private static final Logger LOG = LoggerFactory.getLogger(MQConsumer.class); private volatile boolean running = false; private final Object receiver; private final MethodHandle mh; private final QueueConfig cfg; private final Collection<QueueConfig> backouts; private MQPoolToken token; private MQQueueManager qm; private MQQueue queue; private static final AtomicInteger IDX = new AtomicInteger(0); public MQConsumer(Object receiver, MethodHandle mh, QueueConfig cfg, Collection<QueueConfig> backouts) throws MQException { this.receiver = receiver; this.mh = mh; this.cfg = cfg; this.backouts = backouts; this.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { LOG.error("Consumer {} was termnated due to {}.", t.getName(), e); t.getThreadGroup().uncaughtException(t, e); } }); connect(); } @Override public void run() { this.running = true; Thread.currentThread().setName(receiver.getClass().getSimpleName() + ":" + cfg.getHost() + ":" + cfg.getQueue() + ':' + IDX.incrementAndGet()); final int wait = Integer.parseInt(System.getProperty("JMS_UTIL_WAIT_INTERVAL", "1000")); final int sleep = Integer.parseInt(System.getProperty("JMS_UTIL_SLEEP_INTERVAL", "100")); MQException.logExclude(CMQC.MQRC_NO_MSG_AVAILABLE); while (running) { try { if (qm == null || !qm.isConnected()) { reconnect(); } final MQMessage message = new MQMessage(); final MQGetMessageOptions gmo = new MQGetMessageOptions(); gmo.options = CMQC.MQGMO_WAIT | CMQC.MQGMO_PROPERTIES_AS_Q_DEF | CMQC.MQGMO_FAIL_IF_QUIESCING; gmo.matchOptions = CMQC.MQMO_NONE; gmo.waitInterval = wait > 0 ? wait : CMQC.MQWI_UNLIMITED; queue.get(message, gmo); final String msgId = message.getStringProperty(MQConstants.MQ_JMS_MESSAGE_ID); LOG.info("Read message[{}].", msgId); final MQHeaderIterator it = new MQHeaderIterator(message); String charset = "UTF-8"; while (it.hasNext()) { final MQHeader h = it.nextHeader(); // FIXME: Read charset from header ... for (Object fo : h.fields()) { final MQHeader.Field f = MQHeader.Field.class.cast(fo); LOG.debug("Header {} : {} : {}.", f.getName(), f.getType(), f.getValue()); } } final byte[] data = it.getBodyAsBytes(); if (data.length > 0) { final String text = new String(data, charset); if (LOG.isDebugEnabled()) { LOG.debug("Message[{}]:{}.", msgId, text); } try { Object result = null; switch (mh.type().parameterCount()) { case 2: result = mh.invoke(receiver, text); break; case 3: result = mh.invoke(receiver, data, msgId); break; case 4: result = mh.invoke(receiver, data, msgId, getUsrProperties(message)); break; default: throw new IllegalArgumentException("Invalid number of parameters for consumer " + receiver); } if (result != null && result instanceof Future) { Future.class.cast(result).get(); } } catch (Throwable e) { LOG.error("Failed process message:" + msgId, e); if (backouts != null && !backouts.isEmpty()) { try { backout(data); } catch (CollectionException e1) { LOG.error("Backout failed:" + msgId, e); LOG.error("Please manually recover message {}: {}.", msgId, text); } } else { // TODO: report an error. // queue.putReportMessage(message); LOG.error("No backout for message {}: {}.", msgId, text); } } } else { LOG.error("No data received for message:{}.", msgId); } } catch (MQException e) { if (e.getReason() != 2033) { LOG.error("Faild reading message.", e); reconnect(); } } catch (Exception e) { LOG.error("Faild reading message.", e); reconnect(); } // Wait for another message ... try { Thread.sleep(sleep); } catch (InterruptedException e) { LOG.error("Consumer was interrupted.", e); this.running = false; } } LOG.error("Consumer: {} stopped.", cfg); disconnect(); } /** * Fetch user prperties from a message. */ private static Map<String, String> getUsrProperties(final MQMessage message) { final Map<String, String> headerMap = new HashMap<>(); try { final Enumeration<String> properties = message.getPropertyNames("%"); while (properties.hasMoreElements()) { final String property = properties.nextElement(); headerMap.put(property, message.getStringProperty(property)); } } catch (MQException e) { LOG.error("Failed reading user properties.", e); } if (LOG.isDebugEnabled()) { LOG.debug("HeaderMap[{}]", headerMap); } return headerMap; } /** * Reconnect to MQ server. */ private void reconnect() { try { disconnect(); } catch (Exception e) { LOG.error("Failed disconnect consumer: {}.", cfg); } try { connect(); } catch (Exception ex) { LOG.error("Failed reconnect.", ex); // Failed reconnect, delay next retry ... try { final long duration = Long.parseLong(System.getProperty("JMS_UTIL_RETRY_INTERVAL", "10000")); LOG.info("Retry after {} seconds.", TimeUnit.MILLISECONDS.toSeconds(duration)); Thread.sleep(duration); } catch (Exception e) { LOG.error("Consumer reconnection was interrupted.", e); } } } /** * Backout the message. * * @param payload * The payload of message. * @throws MQException * @throws IOException * @throws CollectionException */ private void backout(byte[] payload) throws MQException, IOException, CollectionException { MQProducer.send(backouts, new ArrayList<QueueConfig>(), BackoutMode.ANY_FAILURE_STOP_THEN_BACKOUT, payload); } /** * Try connect to MQ. * * @param qmh * @throws MQException */ private void connect() throws MQException { LOG.info("Connect consumer: {}.", cfg); this.token = MQEnvironment.addConnectionPoolToken(); try { this.qm = new MQQueueManager(cfg.getManager(), MQUtil.toProperties(cfg)); try { this.queue = qm.accessQueue(cfg.getQueue(), CMQC.MQOO_INPUT_AS_Q_DEF); } catch (MQException e) { qm.disconnect(); LOG.error("Failed access inbound queue {}.", cfg.getQueue()); throw e; } } catch (MQException e) { LOG.error("Faild create queue manager with configuration: {}.", cfg); throw e; } finally { MQEnvironment.removeConnectionPoolToken(token); } } /** * Disconnect from MQ. */ public void disconnect() { LOG.info("Disconnect consumer: {}.", cfg); if (queue != null && queue.isOpen()) { try { queue.close(); } catch (Exception e) { LOG.error("Failed closing queue.", e); } } if (qm != null && qm.isConnected()) { try { qm.disconnect(); } catch (Exception e) { LOG.error("Failed close queue manager.", e); } } if (token != null) { MQEnvironment.removeConnectionPoolToken(token); } } /** * Shutdown the consumer. */ public void down() { LOG.info("Consumer: {} is shutting down.", cfg); running = false; } }
ca607cdaea8fc7a23ae41c481e9463796cc768e8
d3c86d5f49d4e8fcaeeac366c28154c806491ae3
/src/test/java/philaman/cput/limacardealers/model/VehicleBrandTest.java
0d42eda85f151d02740bbdefa5a34938823d40ac
[]
no_license
phielar/LimaCarDealership
7433ecbaa5cb9b7e92f11404ad6f69aff5757e5a
12d48cc5c3753ae573da89bdd482c525b911f61c
refs/heads/master
2021-01-19T14:34:03.785699
2014-03-15T21:52:15
2014-03-15T21:52:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,641
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package philaman.cput.limacardealers.model; import philaman.cput.limacardealers.model.VehicleBrand; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * * @author phila */ public class VehicleBrandTest { public VehicleBrandTest() { } // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // // @Test // public void hello() {} private static VehicleBrand brandtype; @Test public void createTest() { brandtype = new VehicleBrand.Builder("BmW1254sc").name("BMW") .country("Germany").builder(); Assert.assertEquals(brandtype.getId(), "BmW1254sc"); Assert.assertEquals(brandtype.getName(), "BMW"); Assert.assertEquals(brandtype.getCountry(), "Germany"); } @Test public void updateTest() { //Creation of a new Object brandtype = new VehicleBrand.Builder("BmW1254sc").name("BMW") .country("Germany").builder(); //Modification of the object brandtype = new VehicleBrand.Builder("BmW1254mn").name("BMW and MINI") .country("Germany").builder(); Assert.assertEquals(brandtype.getId(), "BmW1254mn"); Assert.assertEquals(brandtype.getName(), "BMW and MINI"); Assert.assertEquals(brandtype.getCountry(), "Germany"); } @BeforeClass public static void setUpClass() throws Exception { } }
[ "phila@phil" ]
phila@phil
86be131685601468dba08471142a4c3ecb5f1943
6fdb1e29e47eeecdbfad5e95b1569bf6d973e7ca
/ChineseCheckers/src/game/Rules.java
96afb892d479f61adac8cac4b53d77e9200a7cbd
[]
no_license
Atlee/P2PChineseCheckers
6fa22ac187c35bea3ef863380a1a3a8540090a31
d09e25296974c9ddcff0e94e6d311a82652d127c
refs/heads/master
2020-07-05T05:42:27.078460
2013-04-27T19:08:42
2013-04-27T19:08:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,727
java
package game; import java.awt.Point; import java.util.ArrayList; public class Rules { private static final Point[][] winningPos = { /*Player 0's winning Positions */ { new Point(6, 16), new Point(5, 15), new Point(6, 15), new Point(5, 14), new Point(6, 14), new Point(7, 14), new Point(4, 13), new Point(5, 13), new Point(6, 13), new Point(7, 13) }, /*Player 1's winning Positions */ { new Point(6, 0), new Point(5, 1), new Point(6, 1), new Point(5, 2), new Point(6, 2), new Point(7, 2), new Point(4, 3), new Point(5, 3), new Point(6, 3), new Point(7, 3) } }; public static boolean checkMove(Player p, Board b, Move m) { ArrayList<Point> jumps = m.getJumps(); if (jumps.size() < 2 || !b.isPlayer(p, jumps.get(0))) { //doesn't make sense for a jump to only have 1 point //or return false if the player is attempting to move a ball that is not theirs return false; } Point from = jumps.get(0); Point to = jumps.get(1); if (b.longJump(from, to)) { // if the first jump is a long jump, assume they are all long for (int i = 1; i < jumps.size(); i++) { to = jumps.get(i); if (!checkLongJump(p, b, from, to)) { //if any jump is invalid return false; } from = to; } } else { if (jumps.size() != 2 || !checkShortJump(p, b, from, to)) { return false; } } return true; } public static boolean checkLongJump(Player p, Board b, Point from, Point to) { if(!b.onBoard(to) || !b.longJump(from, to)) { //the point were going to is off the board return false; } int direction = b.pointsAlignLong(from, to); if (direction == -1) { return false; } //check if a ball is in the middle hole if (!b.checkMiddle(from, direction)) { return false; } return true; } public static boolean checkShortJump(Player p, Board b, Point from, Point to) { if (!b.onBoard(to) || b.longJump(from, to)) { return false; } int direction = b.pointsAlignShort(from, to); if (direction == -1) { return false; } return true; } public static boolean gameOver(Game g) throws Exception{ if (g.getNumPlayers() > winningPos.length) { throw new Exception ("Unknown winning conditions. " + g.getNumPlayers() + " Players and only " + winningPos.length + " Conditions."); } int currentIndex = g.getCurrentPlayerIndex(); Player p = g.getPlayer(currentIndex); boolean thisPlayerWins = true; //for every point the player needs to win, check if their ball fills that point //if not set this player wins to false for (Point pt : winningPos[currentIndex]) { if (!g.getBoard().containsBall(p, pt)) { thisPlayerWins = false; break; } } return thisPlayerWins; } }
15a74151a5b3a34ce788f1898605575fc3172351
b1959b1e6ceb373213cec7eefc9116067447bac0
/cas-subsystem/src/main/java/org/soulwing/cas/undertow/CasAttachments.java
1688de67d93ad119652c36e1040e0231779b4840
[ "Apache-2.0" ]
permissive
ceharris/cas-extension
f14833f6d8c9ebf29a1938ba72d4864e06e2ca30
2e135ea3ada97b6248650092df2e8fcabcfbedea
refs/heads/master
2020-04-11T00:10:48.038258
2019-02-04T20:16:13
2019-02-04T20:16:13
161,378,211
0
0
NOASSERTION
2018-12-11T18:43:52
2018-12-11T18:43:52
null
UTF-8
Java
false
false
1,310
java
/* * File created on Feb 10, 2015 * * Copyright (c) 2014 Virginia Polytechnic Institute and State University * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.soulwing.cas.undertow; import io.undertow.util.AttachmentKey; import org.soulwing.cas.service.Authenticator; /** * Attachment keys used by CAS. * * @author Carl Harris */ interface CasAttachments { AttachmentKey<IdentityAssertionCredential> CREDENTIAL_KEY = AttachmentKey.create(IdentityAssertionCredential.class); AttachmentKey<Boolean> POST_AUTH_REDIRECT_KEY = AttachmentKey.create(Boolean.class); AttachmentKey<Integer> AUTH_FAILED_KEY = AttachmentKey.create(Integer.class); AttachmentKey<Authenticator> AUTHENTICATOR_KEY = AttachmentKey.create(Authenticator.class); }
5f09894c45f1de51c370c8d9855ebeff4d716a43
a8a7ecaa93f33fdce9483a936425b9a231bd4e87
/1804/jt-manage/target/tomcat/work/Tomcat/localhost/jt/org/apache/jsp/index_jsp.java
ba55ca4e40312dbab64c6dbfd9918e2740ffccea
[]
no_license
crazy1083843266/gitLibrary
78381d51ef56b6eaf674c54624773d2d986fb154
f125b1fd907b1ce503417fe3053f2e78cde19cb1
refs/heads/master
2020-03-22T00:14:56.095579
2018-08-01T09:44:30
2018-08-01T09:44:30
139,233,166
0
0
null
null
null
null
UTF-8
Java
false
false
3,037
java
/* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/7.0.47 * Generated at: 2018-06-27 09:43:09 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { } public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("<html>\r\n"); out.write("<body>\r\n"); out.write("<h2>Hello World!</h2>\r\n"); out.write("</body>\r\n"); out.write("</html>\r\n"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }
07d2012d882c753d95df6756987e289f7d0e65cf
cf499d8241e58ef7be4dc0ccf6c928fb96888dbd
/BurrowsWheeler/BurrowsWheeler.java
d0225b78463892960f98c0bc0ef5cd4f63fd5d42
[]
no_license
kiner-shah/CourseraAlgorithms2PrincetonUniversity
fdc7dbf0b2dba95f4882ba7c0b794b1f52d01066
93369af2023d56d456412f9819a2589230f0e560
refs/heads/master
2020-04-23T10:26:57.784904
2019-02-17T09:46:42
2019-02-17T09:46:42
171,104,480
0
0
null
null
null
null
UTF-8
Java
false
false
4,452
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Kiner Shah */ import edu.princeton.cs.algs4.BinaryStdIn; import edu.princeton.cs.algs4.StdOut; import edu.princeton.cs.algs4.BinaryStdOut; import java.util.ArrayList; public class BurrowsWheeler { // apply Burrows-Wheeler transform, reading from standard input and writing to standard output public static void transform() { StringBuilder sb = new StringBuilder(""); while (!BinaryStdIn.isEmpty()) { char c = BinaryStdIn.readChar(); sb.append(c); } String input = sb.toString(); CircularSuffixArray csa = new CircularSuffixArray(input); int lenInput = csa.length(); int targetIndex = -1; StringBuilder sb1 = new StringBuilder(""); for (int i = 0; i < lenInput; i++) { int indexVal = csa.index(i); // index where original input string is there if (indexVal == 0) { targetIndex = i; } // get the last character of suffix starting at indexVal sb1.append(input.charAt((indexVal + lenInput - 1) % lenInput)); } BinaryStdOut.write(targetIndex); BinaryStdOut.write(sb1.toString()); BinaryStdOut.close(); } private static void sort(char[] arr, int[] start, int[] end) { final int R = 256; // radix int[] count = new int[R + 1]; for (int i = 0; i < arr.length; i++) { count[arr[i]]++; } int j = 0; for (int i = 0; i < R; i++) { start[i] = -1; end[i] = -1; if (count[i] > 0) { start[i] = j; int endCnt = j; while (count[i] > 0) { arr[j++] = (char) i; count[i]--; endCnt++; } end[i] = endCnt; // StdOut.println(((char) i) + " " + start[i] + " " + end[i]); } } } private static final int[] start = new int[256]; private static final int[] end = new int[256]; // apply Burrows-Wheeler inverse transform, reading from standard input and writing to standard output public static void inverseTransform() { StringBuilder sb = new StringBuilder(""); int targetIndex = -1; if (!BinaryStdIn.isEmpty()) { targetIndex = BinaryStdIn.readInt(); } while (!BinaryStdIn.isEmpty()) { char c = BinaryStdIn.readChar(); sb.append(c); } String inputStr = sb.toString(); final int inputStrLen = inputStr.length(); // char[] inputArr = inputStr.toCharArray(); char[] sortedArr = inputStr.toCharArray(); sort(sortedArr, start, end); // for (char x : sortedArr) StdOut.print(x); StdOut.println(); int[] next = new int[inputStrLen]; for (int i = 0; i < inputStrLen; i++) { char c = inputStr.charAt(i); if (start[c] != end[c]) { next[start[c]] = i; start[c]++; } } // for (int i = 0; i < inputStrLen; i++) StdOut.println(i + " " + next[i]); StringBuilder sb1 = new StringBuilder(); int s = next[targetIndex]; while (true) { sb1.append(inputStr.charAt(s)); if (sb1.length() == inputStrLen) break; s = next[s]; } String output = sb1.toString(); BinaryStdOut.write(output); BinaryStdOut.close(); } // if args[0] is '-', apply Burrows-Wheeler transform // if args[0] is '+', apply Burrows-Wheeler inverse transform public static void main(String[] args) { String operation = args[0]; switch (operation) { case "+": // inverse transform inverseTransform(); break; case "-": // transform transform(); break; default: // invalid command-line argument StdOut.println("Invalid command line argument: " + operation); break; } } }
a577602fa8bfcdc8e7079deced7c2259f265129f
886262b9f3eb1e86779deae69623e940527a919d
/app/src/main/java/com/nps/roopesh/firebasedb/HomepageActivity.java
65583fb20f9eabd2414c2fa6beb559cbccfcbd1f
[]
no_license
roopesh83/SmartEbinAndroidApp
e5becd49f9a8a1ebef7aff1b51166cb7cae93e96
a1d98f6c69395734d7b3af21f7b26cbcc1b1bcb6
refs/heads/roopesh
2023-02-06T03:49:11.593005
2023-02-04T05:38:58
2023-02-04T05:38:58
125,653,117
0
0
null
2023-02-04T05:38:59
2018-03-17T17:27:06
Java
UTF-8
Java
false
false
3,002
java
package com.nps.roopesh.firebasedb; import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.ValueEventListener; public class HomepageActivity extends AppCompatActivity { //static String s_email,s_password; static FirebaseAuth firebaseAuth; static DatabaseReference databaseUsers; FirebaseAuth firebaseAuth1; DatabaseReference databaseUsers1; String ab=""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_homepage); firebaseAuth1=firebaseAuth; databaseUsers1=databaseUsers; final AlertDialog.Builder builder; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert); } else { builder = new AlertDialog.Builder(this); } try { databaseUsers1.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { String a = ""; for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) { //display_message(builder,"",userSnapshot.toString()); //display_message(builder,"",userSnapshot.getValue().toString()); display_message(builder,"",userSnapshot.child("user_name").getValue(String.class)); // User user = userSnapshot.getValue(User.class); // a = a + user.getUser_name(); // a = a + " "; } ab += a; //display_message(new AlertDialog.Builder(HomepageActivity.this),"title",a); } @Override public void onCancelled(DatabaseError databaseError) { } }); }catch (Exception e){ Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_LONG).show(); } Toast.makeText(getApplicationContext(),ab,Toast.LENGTH_LONG).show(); } void display_message(AlertDialog.Builder builder,String title,String msg){ builder.setTitle(title).setMessage(msg) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).show(); } }
df1e3323f5e6a2c065164c09b63d5d2a5b7ad78a
755b143cce0368b4d05b8f0bab62cb5f2a7973c1
/src/main/java/module/model/QuestionModel.java
ee44a18e99f33879f971ad014ccdc27d224c9040
[]
no_license
dhso/jfinal-demo
c1cc564e1499bb5ab653bd0b29a9db453db0a516
2a0cac817c475febc31b89907c46f80d95f5ee67
refs/heads/master
2021-01-19T00:34:39.241119
2016-12-06T06:37:16
2016-12-06T06:37:16
63,835,666
0
0
null
null
null
null
UTF-8
Java
false
false
603
java
package module.model; import java.util.Date; import com.jfinal.plugin.activerecord.Model; import frame.plugin.tablebind.Table; @SuppressWarnings("serial") @Table(value = "wx_question", pkName = "wq_id") public class QuestionModel extends Model<QuestionModel> { public static final QuestionModel dao = new QuestionModel(); public QuestionModel findQuestion(String qid) { return QuestionModel.dao.findById(qid); } public void addQusetion(String openid, String question) { new QuestionModel().set("wq_openid", openid).set("wq_question", question).set("wq_create_dt", new Date()).save(); } }
dc42ffe3ebb99c72e2d8fdf62aabfe3bb557db18
2f97a20fb7e7a990c323600d04e2fc53d6cc0e74
/src/main/java/org/cp/elements/jdbc/package-info.java
660057d1fa0ca710b4c6dd0c7ab95b29b180bb6b
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
codeprimate-software/cp-elements
71f1d134d03d37f67ba0692114c2bff96cc8d006
157e9dab303361f78f8ef30ae406a7d6d4f750a2
refs/heads/main
2023-09-01T20:51:49.407379
2023-08-30T00:21:08
2023-08-30T00:21:08
29,858,250
2
5
null
null
null
null
UTF-8
Java
false
false
840
java
/* * Copyright 2011-Present Author or Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * The Elements {@literal jdbc} package contains support for the Java Database Connectivity (JDBC) API. * * @author John Blum * @see org.cp.elements.jdbc.AbstractDataSource * @since 1.0.0 */ package org.cp.elements.jdbc;
19fcd6040c18cc3cbbddf90c624e1e459fe9f8f7
385f8aa6d5570b88ee3c4ca71eaeb00f77844f6b
/src/com/agungsetiawan/smsbroadcaster/App.java
160c9d878a3bb2894f871f8b7ec259361227e9f3
[]
no_license
blinkawan/Sms-Broadcaster-KKN
117b00867c415f6ea94c5616b91328e483bba1d6
997ae865748c29dc896efb02df130f26b7b3fec2
refs/heads/master
2020-05-29T09:26:44.197856
2014-01-26T14:43:59
2014-01-26T14:43:59
16,068,732
1
0
null
null
null
null
UTF-8
Java
false
false
3,028
java
package com.agungsetiawan.smsbroadcaster; import com.agungsetiawan.smsbroadcaster.service.GrupService; import com.agungsetiawan.smsbroadcaster.service.InboxService; import com.agungsetiawan.smsbroadcaster.service.KontakService; import com.agungsetiawan.smsbroadcaster.service.OutboxService; import com.agungsetiawan.smsbroadcaster.service.SentItemService; import com.agungsetiawan.smsbroadcaster.ui.FormUtama; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * Hello world! * */ public class App { private static GrupService grupService; private static InboxService inboxService; private static KontakService kontakService; private static OutboxService outboxService; private static SentItemService sentItemService; public static GrupService getGrupService() { return grupService; } public static InboxService getInboxService() { return inboxService; } public static KontakService getKontakService() { return kontakService; } public static OutboxService getOutboxService() { return outboxService; } public static SentItemService getSentItemService() { return sentItemService; } public static void main( String[] args ){ MysqlDataSource dataSource=new MysqlDataSource(); dataSource.setServerName("localhost"); dataSource.setUser("root"); dataSource.setPassword(""); dataSource.setDatabaseName("sms"); try{ grupService=new GrupService(); grupService.setDataSource(dataSource); inboxService=new InboxService(); inboxService.setDataSource(dataSource); kontakService=new KontakService(); kontakService.setDataSource(dataSource); outboxService=new OutboxService(); outboxService.setDataSource(dataSource); sentItemService=new SentItemService(); sentItemService.setDataSource(dataSource); }catch(Exception ex){ JOptionPane.showMessageDialog(null, "Error : \n"+ex); return; } try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); new FormUtama().setVisible(true); } catch (ClassNotFoundException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } } }
9eba5a1d916e880022979b5d5b6814f2802651ab
7006d592aa8fe6edc1913dec2000887533c325a5
/app/src/main/java/com/example/inquallity/themaxshop/adapter/FlowerItemViewHolder.java
abfb19a6fa1834ae4b28cfe715392183d0f84a23
[]
no_license
oaft/TheMaxShop
5087e6feced56f515571a0b542cf1ce07311832d
afd42eeccbfee1705a70f15734f8ccf324a2a001
refs/heads/master
2021-05-06T04:21:19.674427
2018-06-09T16:37:44
2018-06-09T16:37:44
114,927,437
0
0
null
null
null
null
UTF-8
Java
false
false
1,553
java
package com.example.inquallity.themaxshop.adapter; import android.graphics.Bitmap; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.example.inquallity.themaxshop.R; import com.example.inquallity.themaxshop.model.FlowerItem; import butterknife.BindView; import butterknife.ButterKnife; /** * @author Olga Aleksandrova on 03.02.2018. */ public class FlowerItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { @BindView(R.id.tv_flower_item_name) TextView mTitle; @BindView(R.id.tv_flower_item_price) TextView mPrice; @BindView(R.id.iv_flower_item) ImageView mImage; private FlowersListAdapter.OnCardClickListener mListener; private FlowerItem mFlowerItem; public FlowerItemViewHolder(final View itemView) { super(itemView); ButterKnife.bind(this, itemView); itemView.setOnClickListener(this); } public void bindItem(FlowerItem flowerItem) { mFlowerItem = flowerItem; mTitle.setText(flowerItem.getTitle()); mPrice.setText(flowerItem.getPrice()); } @Override public void onClick(View v) { mListener.onCardClick(v, mFlowerItem.getTitle(), mFlowerItem.getImageUrl(), mFlowerItem.getPrice()); } public void setOnCardClickListener(FlowersListAdapter.OnCardClickListener listener) { this.mListener = listener; } public void bindImage(Bitmap bitmap) { mImage.setImageBitmap(bitmap); } }
94e172c7b5b7e651887003049c6de83b8ea20132
1d4e8ed7b846b7f7a9f601caba79fa6faca629eb
/src/main/java/org/wjh/solar/websocket/SolarWebSocketClient.java
5c5ee84e6c40b9cd10d8181a3ec10c9ed6484a23
[]
no_license
efficientpower/solar
f119a0375853906daeab443edbf79065ad007d5b
20f5d4d691aa4e3dea7f26803fe61ff39ae44b5c
refs/heads/master
2021-01-21T02:10:14.717394
2016-09-03T05:45:12
2016-09-03T05:45:12
58,601,665
1
0
null
null
null
null
UTF-8
Java
false
false
735
java
package org.wjh.solar.websocket; import java.io.IOException; import javax.websocket.ClientEndpoint; import javax.websocket.OnError; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; @ClientEndpoint public class SolarWebSocketClient { @OnOpen public void onOpen(Session session) { System.out.println("Connected to endpoint: " + session.getBasicRemote()); try { session.getBasicRemote().sendText("Hello"); } catch (IOException ex) { } } @OnMessage public void onMessage(String message) { System.out.println(message); } @OnError public void onError(Throwable t) { t.printStackTrace(); } }